struct MAPTILE {
int x;
int y;
int collisionLayerOne;
int collisionLayerTwo;
int animLayerOne;
int animLayerTwo;
char layerone[80];
char layertwo[80];
};
MAPTILE *maptiles = new MAPTILE[1]; // dummy
maptiles[0]->y = 0;
maptiles[0]->x = 0;
maptiles[0]->collisionLayerOne = 0;
maptiles[0]->collisionLayerTwo = 0;
maptiles[0]->animLayerOne = 0;
maptiles[0]->animLayerTwo = 0;
maptiles[0]->layerone = "NONE";
maptiles[0]->layertwo = "NONE";
Dynamic Array of Structs
I can't figure out what is wrong with this code:
I'm getting the following error:
syntax error before `->' token [all of them]
I've been working on this for a few hours now so I'm probably just missing something really obvious... but I don't see anything wrong with this code!
maptiles may be of type MAPTILE*, but maptiles[0] isn't, because the [0] states to dereference the pointer to the first element in the array.
Change "->" to "." as mentioned beforehand.
Change "->" to "." as mentioned beforehand.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement