I want to have a deep copy of a vector with pointers to objects, but the object can be either C or B. I know I'm confused (as I explain it), let me illustrate.
class A { A(const A& copyme) { } void UnableToInstantiateMeBecauseOf() =0; }; class B { B(const B& copyme) : A(copyme) {} }; class C { C(const C& copyme) : A(copyme) {} }; std::vector<A*>* CreateDeepCopy(std::vector<A*>& list) { std::vector<A*>* outList = new std::vector<A*>(); for (std::vector<A*>::iterator it = list.begin(); it != list.end(); ++it) { A* current = *it;
How to create a copy of an object that you donโt have what inherited the type?
source share