I'm assuming you have a structure or class called Tile. Otherwise the compiler won't know what Tile is. This error is basically due to a spelling mistake unless u havent created the object.
Otherwise it should be fine.
Post your code on here inside [sourc e] [/sourc e] tags (with no space befpre the 'e'.
Exactly, your variable 'NewTile' probably goes out of scope if it causes this error message. The pointer variable you declared behaves just like an ordinary int, only that it contains the address of a chunk of memory (namely an instance of your 'Tile' class) which will not be freed if you loose that address. In other words, while the memory you reserved is not bound to a scope, the pointer variable is.
Use it like this:
struct Tile { int a, b, c; };int main() { Tile *NewTile = new Tile(); NewTile->a = 123; delete NewTile;}
(Personally, if I had to educate someone about dynamic memory allocation, I wouldn't even mention there was a heap until the usage of new/delete had been covered completely, just assuming new takes memory out of thin air ;))
With your permission, GameDev.net uses analytics cookies to understand how people use the platform.
You can accept analytics or continue with necessary cookies only.
Learn more