listing classes

Nov 7, 2013 at 6:51pm
how do I go through the classes created?
example:
every time I run this line:
 
  Module * mod = new Module ();

I create a new class ..
I wonder how do I go through all the classes that were created during program execution.

Tranks
Nov 7, 2013 at 7:07pm
Its not called creation of classes, but making objects of certain type.

You do go through the objects by not losing the pointers.
Nov 7, 2013 at 7:12pm
Sounds to me like you are using one pointer and creating multiple objects with new and not deleting the old ones which is a memory leak and should be impossible to access the old ones unless you use an array to store the memory addresses. What you should do is just create an array of the objects then when you are done with them delete them. You can then use the offset( position in array ) to access the elements:

 
Module *mod = new Module[5];


Or if you don't want to call the constructor right away you can use operator new and allocate raw memory then later on call the constructor when you actually need the object.
Nov 8, 2013 at 12:44am
Tranks giblit :)
Topic archived. No new replies allowed.