I'm having some difficulty figuring out how to delete the objects I new'ed during run-time. I'm using a heterogeneous collection.
const int SIZE = 4; myBase* objs[SIZE]; objs = new myChild1(); objs = new myChild2(); objs = new myChild3(); objs = 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.