Consider the following code:
class Base
{
protected:
virtual void methodDefinedInBase() = 0;
}
Class Derived: private Base
{
public:
void someMethod();
protected:
virtual void methodDefinedInBase()
{
std::cout<<"From B"<<std::endl;
}
}
In the above code, I can create object of type "Derived". C++ allows me access to the method "methodDefinedInBase()" from "someMethod()" in Derived class. But, how do I create an object of type "Base" ?
Thanks,
Vishnu.
As Beta noted in a comment, you can't instantiate an abstract base class (one with pure virtual methods.) You can only instantiate derived classes that implement those pure virtual methods. That's true regardless of whether you're using public or private inheritance.