All mock tests are FREE till 31 December — register to save your progress

Let A be the base class in C ++ and B be the derived class from A with protected inheritance. Which of the following statement is false for class B?

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: D. Object of derived class B can access public base class data

Explanation

With protected inheritance, A's public members become protected in B, so code outside B — including through a B object — cannot access them. B's member functions can still use A's public and protected members, but never its private ones.

More Programming Languages and Computer Graphics questions