When the inheritance is private, the private methods in base class are _____…

2015

When the inheritance is private, the private methods in base class are _____ in the derived class (in C++).

  1. A.

    inaccessible 

  2. B.

    accessible

  3. C.

    protected

  4. D.

    public

Attempted by 357 students.

Show answer & explanation

Correct answer: A

Answer: Private methods in the base class are inaccessible in the derived class.

  • Private members of a class are accessible only within that class and its friends; derived classes cannot access them.

  • Under private inheritance, the base class's public and protected members become private in the derived class, but the base class's private members remain inaccessible to the derived class.

  • Therefore, private methods declared in the base class cannot be called from the derived class.

Key point: Inheritance changes how public and protected members are reclassified, but it does not grant access to the base class's private members.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Mppsc Assistant Professor