Except for the fact that it can be called from the derived class overridden method, the pure virtual function doesnot seem to be able to be called anywhere! What then, is the use of its body? Eg.
class base
{
public:
virtual void fun()=0
{
cout<<"I have been called from derived class"<<endl;
}
};
class derived:public base
{
public:
void fun()
{
cout<<"I am the derived class"<<endl;
base::fun();
}
};
void main()
{
derived d;
d.fun();
}
It is used in the exact way you mentioned in the question, that there is some common logic that can be reused by the derived classes but at the same time you want to force the derived classes to provide the implementation for the non-common part.