i figured out the problem...i had objects that were not on the heap...hence i was trying to delete objects on the stack...
i was calling this function like this...
Code:
int main(void) {
vector<Shape *> shapes;
Square s0(42,1);
Shape *s1 = new Square(2,4);
Shape *s2 = new Circle(2,4);
Shape *s3 = new Triangle(2,4);
//Shape *s4 = &s0;
shapes.push_back(s1);
shapes.push_back(s2);
shapes.push_back(s3);
//shapes.push_back(s4);
printContainer (shapes);
return 0;
}
is there anyway to tell if i need to delete an object or not from a container...
say in a container i have objects on/off the heap...and obviously i only want to delete the objects that are on the heap...can i do that?