Hi all.
Can someone explain something to me?
You will have to explain as if talking to a child, because I've tried to understand this several times, and can't wrap my head around it. I suspect I'm just missing some core way of thinking that my aging programmer brain can't change to adopt.
In C++, if you want to do auto garbage collection-- to stop using the "delete" keyword at all... what do you do?
For instance:
What do you do to make this do the same thing?Code:int *anInt=new int; delete anInt;
Wait, though... I *think* I can just, only just, understand how to do the above with a smart pointer. Which seems like a crappy solution because I'd have to use the smart pointer variable type for everything... But what about this:Code:int *anInt=new int; anInt=NULL; // Magically deletes it! Wow
Since all the rest of the world's lazy programmers are no longer using "delete," and since virtually all new languages don't use it... I want to understand it, but in C++ so I understand what's happening in the core of things. Or, rather, I should say, I want to continue to write in C++ for the time being, but get into the "groove" with auto garbage collection so that when the time comes that C++ games are no published (such as with XBox, thanks Microsoft... for turning into the company Apple used to be), I can adapt, and port my existing code.Code:Object *anObject=new Object; ObjectList+=anObject; AnotherObjectList+=anObject; // // Do stuff // ObjectList-=anObject; AnotherObjectList-=anObject; // No longer in any lists! anObject Magically deleted!
Thanks a million!
--John


Reply With Quote