Computer Science - Object Oriented Programming Using C++ - Discussion

Discussion Forum : Object Oriented Programming Using C++ - Section 8 (Q.No. 17)
17.
Assume a class Derv that is privately derived from class Base. An object of class Derv located in main() can access
public members of Base
protected members of Base
private members of Base
public members of Derv
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
4 comments Page 1 of 1.

Sabari said:   3 years ago
The Correct answer is D.

In private inheritance, the access status of parent class members in the derived class is restricted. The private, protected and public members of parent class all become the private members of derived class.

In private inheritance, the private, protected and public members of derived class can access the protected and public members of parent class.

However, the object of the derived class can only access public members of derived class directly.

The object of the parent class cannot access any member of parent class directly.

In private inheritance, all public and protected members of base class become private members in child class objects.

Abhijit Deshmukhya said:   5 years ago
Public members of base class will become private in derived class if it is privately inherited. So it will be not accessible by an object of derived class which is located in main () rather it will be accessible by only the member functions of the base class.

Namrata said:   6 years ago
The Correct answer is D.

Omar Othman said:   1 decade ago
The correct answer is D.

Post your comments here:

Your comments will be displayed after verification.