Consider the class hierarchy shown below.
class A
{ int a;
protected:
int b;
public:
int c; };
class B: protected A
{ };
Class C: public B
{ };
Which data members of class A are accessible
- in class B
-in class C
-in main function
Justify your answer.
c and b are accessible in class B since b is inherited by class B
only c is accessible in class C since c is public
only c is accessible in the main class because it is public and can be accessed from anywhere.
Comments
Leave a comment