I've been trying to make a text-based game and I'm constantly getting no execution error and no compilation errors. Everything's returning 0.
I have a player obj already created in a class so I will leave out that large boring snippet of code. All i've been trying to do is use a function that should be running from what I see (displayMenu). I know compilers read top to bottom so how come Im not getting a single stitch of input back?
@helios Im deleting the pointer I used for level one, each level I pass the Player object so I know whose playing the level and their attributes. When I finish the level I wanna delete the pointer and since I have multiple level it became something repetitive in levels so I made it a function to call and you pass your pointer through and delete it. And yea Im not using a proper IDE with a good compiler so when I get home Ill throw it in VS and see what I get. For now thats what Im doing but Im going to make a destructor for it
Ah okay, can you explain in more detail why having p = NULL; first leaks it? Thanks :) It just made sense to me as a noob to set the pointer to null before I delete it for extra saftey. Would it be more logical to simply delete the pointer and not include the NULL statement?
If you null before deleting, how do you know what to delete?
Imagine I give you my phone number, but before I leave I take the paper I gave you and burn it, and tell you "don't forget to call me!" Are you going to be able to call me?
In that particular case yes, nulling the pointer makes no difference, because you're only nulling the local copy in the the clean() function. When clean() returns that pointer disappears anyway. In fact, I would not be surprised if the compiler optimizes that assignment away.