In case of private inheritance in C++, which of the following correctly…

2018

In case of private inheritance in C++, which of the following correctly represents the accessibility of the data variables from second derived class?

  1. A.

    Private variables: Yes, Protected variables: No, Public variables: Yes

  2. B.

    Private variables: Yes, Protected variables: No, Public variables: No

  3. C.

    Private variables: Yes, Protected variables: Yes, Public variables: Yes

  4. D.

    Private variables: No, Protected variables: No, Public variables: No

Attempted by 104 students.

Show answer & explanation

Correct answer: D

In C++, private inheritance converts all public and protected members of the base class into private members of the derived class. Consequently, a second derived class cannot access these members because they are treated as private in the intermediate class. Original private members remain inaccessible to all derived classes regardless of inheritance type.

Explore the full course: Uppsc Polytechnic Lecturer 2025 Cs