void functionA()
{
cout << "\nI am in Function A of Class A" << endl;
}
};
class B : private A
{
public:
void functionB()
{
cout << "\nI am in Function B of Class B" << endl;
}
};
class C : public A
{
public:
void functionC()
{
cout << "\nI am in Function C of Class C" << endl;
}
};
int main()
{
A a;
B b;
C c;
//a.functionA();
b.functionB();
b.functionA(); // error generated here
return 0;
}
I am trying to keep the member functions of Class A secret.
But Class B and Class C can access them and use them
However, member functions of Class A should not be accessed directly.
Anybody who wish to access member functions of Class A must access via Class B or C
Class A is like a base class
Class B and C and derived from Class A.
Please help me in understand this concept of public protected and private
And how to resolve this situation.