The actual problem is failing to substitute a derived object for a base object.
Your main shoud be:
-
base* ptr = new derived;
-
ptr->paint(); //calls derived::paint()
-
That is, when you have virtual functions you are designing the interface to be inthe base class but you will actually create derived objects and use them as base objects. This is fundamental polymorphism.
The pure virtual function only means that you can't call the method using an object of the class that declares the pure virtual function.
Since the base class defines the interface, the methods the user is call should be public and none of these should eb private. Instead, the base public methods call base private virtual methods and it is these that are overriden in the derived class.
Most likely, the overiding method can be private in the derived class.
Your base::getobject() that returns a base* is bad design. Methods like this belong in a Factory class and not your base class. It is the Factory that creates the derived object and returns its address as a base*.