I think its because the base class data members and methods wont be accessible , but I\'d like some more clarity on this. Also, is this the reason why polymorphism (using vi
Here is an example which will help you to understand better
class Base{
public:
int foo;
};
class Derived: private Base{
public:
int bar;
};
Now in this program lets see what the derived class object can do. The derived class object can
Now lets see what happens if a Base pointer can do if it is made to point to such object. For the base class pointer,
So now you can see the ambiguity that the base pointer will face if it points to an object of a class inherited under private relation.
Ambiguity: According to the derived class object foo is private, but the base pointer considers it to be public.
So the morale of private or protected inheritance is lost if such things were allowed. I hope this clears your doubt.