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

2018

In case of public inheritance in C++, which of the following correctly represents the accessibility of the data variables from 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 126 students.

Show answer & explanation

Correct answer: C

In C++ public inheritance, private members of the base class remain inaccessible to the derived class. Protected and public members are accessible within the derived class, though their accessibility levels may change relative to external code.

Explore the full course: Uppsc Polytechnic Lecturer 2025 Cs