C++: Deep copying a Base class pointer
You need to use the virtual copy pattern: provide a virtual function in the interface that does the copy and then implement it across the hierarchy: struct base { virtual ~base() {} // Remember to provide a virtual destructor virtual base* clone() const = 0; }; struct derived : base { virtual derived* clone() const … Read more