/*C++ program to demonstrate example of private simple inheritance.*/
using namespace std;
int x; //can access by the derived class
void setVal(int v)
class B:private A
setVal(10); //accessing public member function here
//protected data member direct access here
cout << "value of x: " << x << endl;
B objB; //derived class creation
value of x: 10
/*Here x is the protected data member of class A, class A is inherited privately to class B.
In, private inheritance only protected data member and member functions can be accessed by the derived class.
total answers (1)
start bookmarking useful questions and collections and save it into your
own study-lists, login now to start creating your own collections.