how do you memory manage a class in c++? i started by giving it two static lists, live objects and deadobjects, and retain and release functions like in obj-c, and even a collect garbage method. where do i go from here?
Name:
Anonymous2012-01-01 13:00
Retain and Release functions sound like explicit memory management. Why not use smart pointers to implicitly delete objects when they are no longer referenced?
Name:
Anonymous2012-01-01 14:09
What do you mean by "manage memory"? Overloading new and delete operators to handle allocations yourself, or do you want garbage collection like java and C#?
Name:
Anonymous2012-01-01 18:37
you'll need some mechanism for managing references that objects have to other objects. And keeping track of what set of objects are referable from the stack. When it is time to collect, you'll need to do some kind of traversal over the live objects. You could look up specific GC techniques, and maybe go from there if you wanted to. Making a special smart pointer for references to objects from the stack could be useful.