edited by
7,165 views
4 votes
4 votes

If a class $C$ is derived from class $B$, which is derived form class $A$, all through public inheritance, then a class $C$ member function can access

  1. only protected and public data of $C$ and $B$
  2. Only protected and public data of $C$
  3. all data of $C$ and private data of $A$ and $B$
  4. public and protected data of $A$ and $B$ and all data of $C$
edited by

2 Answers

Best answer
11 votes
11 votes

option D

WHy?

summarize the different access types according to who can access them in the following way:

Access public protected private
Same class yes yes yes
Derived classes yes yes no
Outside classes yes no no
selected by
1 votes
1 votes

When deriving a class from a public base class,public members of the base class become public members of the derived class and protected members of the base class become protected members of the derived class. A base class's private members are never accessible directly from a derived class, but can be accessed through calls to the public and protected members of the base class.

Hence,Option(D)Public and protected data of A and B and all data of C.

Answer:

Related questions

4 votes
4 votes
2 answers
1
asu asked Jul 4, 2016
4,275 views
Configuration management is not concerned withcontrolling changes to the source codechoice of hardware configuration for an applicationcontrollling documentation changesm...
0 votes
0 votes
1 answer
3
nadosha asked 3 days ago
44 views
A constructor cannot be explicitly called by the client program. true or false?
0 votes
0 votes
0 answers
4
nadosha asked 3 days ago
33 views
A program that includes the file containing a class declaration is called a ________ program of the class.