what to do when.... (things go bad)

Started by
30 comments, last by graveyard filla 19 years, 10 months ago
quote:Original post by graveyard filla
thanks tal, i didnt think calling new would change the value of the pointer which called it... i guess it makes sence though since your asking for a new hunk of memory, so technically, when you do this:

int *some_int;

this is a pointer which not only points to garbage, but also STORES garbage?

thanks for clearing things up.

ps - to the other guys, thanks for your help but i already solved the problem, it was because of the pointer changing when i called new, read my other post


Your mental model of pointers is giving you the wrong idea. pointers are nothing more than variables that hold addressess, just like an integer is a variable that holds whole signed numbers. It doesn't physically point to memory inside your computer it just makes it easier to think that way. Techincally you could just as well use integers to store the address but it isn't a good idea of course.

[edited by - snk_kid on June 11, 2004 7:32:00 PM]
Advertisement
no, i totally understand that a pointer is a variable that stores a memory address.... but when i saw new, i thought it meant "make a new object who lives out in space, and this memory address stored at this pointer will be pointing to it".. i guess it does make more sence as "make a new object who lives in space, and this pointer''s address will now be this objects address"...

FTA, my 2D futuristic action MMORPG

This topic is closed to new replies.

Advertisement