GNU nano 2.9.1 test.cpp Modified
/********************************************************************************************************
*************Designed and Developed by V2Geeks******************************************
********************************************************************************************************/
// Example of protected member inherited privately
#include<iostream.h>
#include<conio.h>
class A {
protected:
int a; // visible to child B but not to C
public:
A()
{
a=5;
}
};
class B : private A
{
public :
void show()
{
cout<<"a="<<a;
}
};
class C : public B
{
void showC()
{
cout<<"a="<<a; // is not further inheritable
}
};
void main()
{
B objB;
C objC;
clrscr();
objB.show(); // will print a=5 (since protected member privately inherited is //
// visible but not further inheritable)
objC.showC(); // Error a is not further inheritable
getch();
}