www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/30/20:30:19

From: dmt AT bigfoot DOT com (Jeff W./DMT)
Newsgroups: comp.os.msdos.djgpp
Subject: "Non-Aggregate type"?????
Date: Thu, 30 Apr 1998 23:26:33 GMT
Organization: ZipLink -- America's Hottest ISP
Lines: 99
Message-ID: <354907d7.591790@news.ziplink.net>
NNTP-Posting-Host: chi-ip-1-215.ziplink.net
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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???
 --Jeff W.

 "The finding of DMT in normal human body fluids
 opens up interesting moral and legal questions.
 Since DMT is illegal, as is 'any substance, compound
 or mixture' containing DMT, it would seem that we
 are all guilty of possesion of a controlled substance"
 -Jonathon Ott

 My weird, trippy page:
 http://www.geocities.com/SunsetStrip/Alley/3450/index.html

- Raw text -


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