In trouble with inheritance and C++
I'm in trouble with the following code. Why class mother is inaccessible from class granddaughter if class daughter (from which granddaughter inherits) inherits from class mother with the access specifier set to PRIVATE? I can't create objects nor pointers. Why? What is the logic behind this behavior? What could be the problems if I use a mother object in the granddaughter class? And, connected to this last question, why if class daughter inherits from class mother with the access specifier set to PUBLIC or PROTECTED I can create a mother object into granddaughter class? Do those problems not come back to me? #include <iostream> #include <stdio.h> using namespace std; class mother { public: mother(){}; }; class daughter : private mother { public: daughter(){}; }; class granddaughter : public daughter { public: granddaughter(){}; mother _mother; // ERROR mother* mother; // ERROR }; int main(void){return 0;}