Answer to Question #239536 in C++ for how

Question #239536

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.


1
Expert's answer
2021-09-24T00:04:00-0400

Members of class A accessible in class B are b and c this is because B inherits protected members of A while c is public.

Members of class A accessible in class C is c because c is public and is accessed from anywhere.

In main function c is accessible since it is public and can be accessed from anywhere.


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS