I created an abstract class and then created child classes that inherit this abstract class.
class A{
public:
virtual A* clone() const = 0;
virtual A* create() const = 0;
~virtual A(){};
// etc.
private:
A(){};
};
child classes
class B: public A{};
class C: public A{};
I can now populate a vector with these classes using a pointer of type A and access the child classes via polymorphism.
vector<A*> Pntr;
The problem is I want each child class to deal with its own memory release, kind of like RAII. However RAII doesn't work with virtual destructors. Is there a way I can do this?