I'm having some difficulty figuring out how to delete the objects I new'ed during run-time. I'm using a heterogeneous collection.
Simplified Example:
const int SIZE = 4;
myBase* objs[SIZE];
objs[0] = new myChild1();
objs[1] = new myChild2();
objs[2] = new myChild3();
objs[3] = new myBase();
//I tried:
for(int i = 0; i < SIZE; ++i)
delete objs[i];
//but it caused run-time errors (It didn't show any specific errors but would stall the program and not allow it to close.)
How do I properly delete these new'ed objects to prevent memory leaks?
Thanks for any help.