The simplest way to replace CObject is to use the standard template library.
Something like this will give you something with almost identical functionality (as well as being efficient, exception-safe and so on):
Code:
#include <list>
typedef CList std::list<void *>;
(if memory serves, this is roughly how CList is implemented internally.)
You can also improve your code by using
std::list<type> to create a list of items of type
type; the compiler will check that you never inadvertently try to add an object of the wrong type.
If you're using Qt or the KDE libraries, then CObject just becomes QObject. Otherwise, you can just use an empty base class (unless you need specific methods of CObject, which then you'll have to write yourself):
This has the advantage that some compilers can optimize away the CObject class so that it takes up no memory in base classes, although pointers to CObjects will still be virtual. You'll still have to explicitly derrive classes from CObject, however.