delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/02/22:04:45

From: dmt AT bigfoot DOT com (Jeff W./DMT)
Newsgroups: comp.os.msdos.djgpp
Subject: What does this error message mean??
Date: Sat, 02 May 1998 17:09:36 GMT
Organization: ZipLink -- America's Hottest ISP
Lines: 95
Message-ID: <354b5275.808827@news.ziplink.net>
NNTP-Posting-Host: chi-ip-1-142.ziplink.net
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I got the following error message trying to access a public class
function:

ERROR: Request for member GetTile() in MapClass::Tiles in
non-aggregate type MapStruct **

Below is what Mapstruct and MapClass look like:

typedef struct MapStruct
//just contains all the other structures into 1
{
 BaseType base;
 FringeType fringe;
 ObjType obj;
 RoofType roof;
};



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;
};


The way this works is that I can declare a 2D array to be of type
MapClass, and can then access the members using Variable[y][x].field,
or functions by Variable.Function().  Pleeease help!
 --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 trippy page:
 http://www.geocities.com/SunsetStrip/Alley/3450/index.html
 The official Smack-Biiiiiiiatch homepage =):
 http://members.tripod.com/~psilocyn/smackbitch.html

- Raw text -


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