delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/12/28/11:34:51

From: "Grigoriy Strokin" <grg AT philol DOT msu DOT ru>
Newsgroups: comp.os.msdos.djgpp
References: <67uo86$u$1 AT cubacola DOT tninet DOT se>
Subject: Re: Plain C++ question about classes...
Date: Sat, 27 Dec 1997 17:49:28 +0300
Lines: 23
NNTP-Posting-Host: isabase.philol.msu.ru
Message-ID: <34a5157a.0@boy.nmd.msu.ru>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

>CImageBuffer  buffer1(320,200);   /* creates a 320x200 buffer */
>CImageBuffer  buffer_array[100](320,200);  /* this thing is BAD */
>
>the first line creates a buffer and sends the two arguments for the
>constructor, but the second line is illegal, because it's an array. How Do
i
>write the second line in the right way ?????????????????

You would use pointers instead of static arrays and then initialize each
object within a cycle:

CImageBuffer **buffer_array = new (CImageBuffer*)[100];
int i;
 for (i=0; i < 99; i++)
 {
  buffer_array[i] = new CImageBuffer(320, 200);
  buffer_array[i]->SomeOtherActions();
  ...
}




- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019