www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/04/08:58:25

Message-Id: <m0yWKmY-000S3YC@inti.gov.ar>
Comments: Authenticated sender is <salvador AT natacha DOT inti DOT gov DOT ar>
From: "Salvador Eduardo Tropea (SET)" <salvador AT inti DOT gov DOT ar>
Organization: INTI
To: dmt AT bigfoot DOT com (Jeff W./DMT), djgpp AT delorie DOT com
Date: Mon, 4 May 1998 10:03:31 +0000
MIME-Version: 1.0
Subject: Re: "Non-Aggregate type"?????
In-reply-to: <354907d7.591790@news.ziplink.net>

dmt AT bigfoot DOT com (Jeff W./DMT) wrote:

> I have the following 2 classes declared:
> 
> class TiledMap
> {
> public:
>   TiledMap (void)
>   {
>     width = 20; //arbitrary starting map size of 20x15
>     height = 15;
>     size = width * height;
>     data = new MapStruct[size];
>   }
>   ~TiledMap (void)
>   {
>     delete[] data;
>   }
> 
>   int resize (const int _width, const int _height)
>   {
>     if ((_width <= 0) || (_height <= 0))
>       return -1;
>     width = _width;
>     height = _height;
>     if ((width * height) > size)
>       {
> 	delete[] data;
> 	size = width * height;
> 	data = new MapStruct[size];
>       }
>     return 0;
>   }
> 
>   MapStruct& tile (const int _x, const int _y)
>   {
>     /* FIXME: test for input out of range.  */
>     return data[_y * width + _x];
>   }
> 
>   /* operator[] exhibits implementation details
>    * (that tiles on each line are in one array).
>    * But it can be faster to access than `tile' above,
>    * if indexes values are known at compile time. */
>   MapStruct* operator[] (const int _y)
>   {
>     /* FIXME: test for input out of range.  */
>     return &data[_y * width];
>   }
> 
>  int  GetWidth(void) {return width;}
>  int  GetHeight(void) {return height;}
>  int  GetSize(void) {return size;}
>  void SetWidth(int a) {width = a;}
>  void SetHeight(int a) {height = a;}
> 
>  private:
>   int width;
>   int height;
>   int size;
>   MapStruct* data;
> };
> 
> 
> 
> class MapClass
> {
>  public:
>   TiledMap Tiles; //dynamic map 2D array
>   int xstart, ystart; //top left corner at which to begin drawing
> tiles
>   int TileX, TileY; //dimensions of largest tile bitmap
>   int SX_Tiles, SY_Tiles; //# of tiles that can be displayed in x/y
> dir on screen
> 
> //S stands for Screen =)
> 	void LoadMap(char filename[80]); //reads in map data
>   void SaveMap(int x, int y); //saves a map of size X x Y
>   void InitMap(void); //initializes a map, only if not LOADingMAP
>   void BlitMap(BITMAP *buffer, DATAFILE *data); //blits the map to the
> buffer
> };
> 
> 
> the problem is that within my MapClass functions, whenever I try to
> access any function of TiledMap (i.e. RESIZE or GETWIDTH), DJGPP gives
> me the error: ERROR resize IS OF NON-AGGREGATE TYPE.  However, I can
> take that aove same TiledMap Class, insert it into a new C++ file, and
> run a test file accessing those functions withiout a problem.  How do
> I fix this error???

Please tell the exact line and code where the error is reported. This error is 
commonly reported when you use . instead of ->.

SET
------------------------------------ 0 --------------------------------
Visit my home page: http://set-soft.home.ml.org/
or
http://www.geocities.com/SiliconValley/Vista/6552/
Salvador Eduardo Tropea (SET). (Electronics Engineer)
Alternative e-mail: set-soft AT usa DOT net set AT computer DOT org
ICQ: 2951574
Address: Curapaligue 2124, Caseros, 3 de Febrero
Buenos Aires, (1678), ARGENTINA
TE: +(541) 759 0013

- Raw text -


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