edited by
7,837 views
5 5 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$

2 Answers

Best answer
11 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 1 vote

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:
Position:
Show:

Related questions

2 2 votes
1 answers 1 answer
2.1k
2.1k views
go_editor asked Aug 20, 2016
2,120 views
Implicit return type of a class constructor isnot of class type itselfclass type itselfa destructor of class typea destructor not of class type
0 0 votes
1 1 answer
7.5k
7.5k views
admin asked Mar 31, 2020
7,457 views
Given a class named student, which of the following is a valid constructor declaration for the class?Student student(){}Private final student(){}Student(student s){}Void ...
0 0 votes
1 1 answer
1.5k
1.5k views
admin asked Mar 31, 2020
1,479 views
An object can have which of the following multiplicities?ZeroMore than oneOneAll of the above
0 0 votes
1 1 answer
4.1k
4.1k views
admin asked Mar 31, 2020
4,134 views
An operation can be described as:Object behaviorFunctionsClass behavior(A),(B)