UGC NET CS 2019Programming Languages and Computer Graphics › Programming in C++Verified
UGC NET CS 2019 PYQ: Let $A$ be the base class in $\text{C++}$ and $B$ be the derived class from $A$ with protected inheritance.…
Let $A$ be the base class in $\text{C++}$ and $B$ be the derived class from $A$ with protected inheritance. Which of the following statement is false for class $B$?
- AMember function of class $B$ can access protected data of class $A$
- BMember function of class $B$ can access public data of class $A$
- CMember function of class $B$ cannot access private data of class $A$
- DObject of derived class $B$ can access public base class dataCorrect answer
Answer
(D) Object of derived class $B$ can access public base class data
Approach
Apply C++ protected inheritance access rules: public and protected members of A become protected in B, private members stay inaccessible.
Reviewed by UGC IQ Editorial Team.