Original Post
Hi, I have no idea what the best way to deal with memory allocation is. I'm using vc++ express. I want to be able to, CDevice * d = createDevice (); and then, d->drop (); and I want all devices to be automatically updated under a single function call run (), while (run ()) { /*u get the idea*/ } I've written my attempt at doing this, using c++ new and delete, but it's problematic, because it requires a huge tonne of code devoted to each and every object that I want to have those features. I can post it if anyone wants, but it's a bit long so I won't post it now. My method is to keep a list of pointers to all the objects of a type (type is passed using an enum) for every type. That list is updated dynamically so it can have an unlimited number of list items. Every time an object is created, the list is given the pointer and the type to add. Then the list will call the updt() member of every object in the list. There has to be a better way. A way that doesn't involve object type specific code. It would be great if I could just have a base class that deals with reference counting / dynamic memory. that way, class CDevice : public CRef will be just about sufficient. Sorry if I'm hard to understand, this is a hard topic to explain. A link to an article on this very topic would be tops! Thx [Edited by - spudmuncher on March 28, 2009 10:14:03 PM]