OK suppose I had a code like this
Code like this does compile, but I don't think I'm grasping this correctly. Basically I'd like to have a container of new classes, and be able to access them (let's say 4 different classes all pushed onto the vector). My concerns are, does this cause any sort of memory leaks (let's say even with the class destructors being all in order). Does this just make a copy of the derived classes? From what I can understand the vector elements are just pointers to whatever objects.Code:vector<base *> vec; vec.push_back(new derived()); delete vec;
Am I overthinking this?