Consider the following inheritance in C++ class BASE: class BASE { int B1;…
2022
Consider the following inheritance in C++ class BASE: class BASE { int B1; protected: int B2; public:
- A.
B2 → protected, FUNB() → public
- B.
B2 → protected, FUNB() → protected
- C.
B2 → public, FUNB() → public
- D.
B2 → private, FUNB() → protected
Attempted by 150 students.
Show answer & explanation
Correct answer: A
In public inheritance in C++: Public members of the base class remain public in the derived class. Protected members of the base class remain protected in the derived class. Private members of the base class are not accessible in the derived class. Here: B2 is protected in BASE → remains protected in DERIVED. FUNB() is public in BASE → remains public in DERIVED.