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

2018

In case of protected 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: Yes, Public variables: Yes

  2. B.

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

  3. C.

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

  4. D.

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

Attempted by 101 students.

Show answer & explanation

Correct answer: C

In protected inheritance, base class private members remain inaccessible to all derived classes. Public and protected members of the base class become protected in the first derived class, allowing access from a second derived class within its scope. Therefore, private variables are inaccessible while protected and public base variables are accessible as protected.

Explore the full course: Uppsc Polytechnic Lecturer 2025 Cs