Skip to content

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$?

  1. A
    Member function of class $B$ can access protected data of class $A$
  2. B
    Member function of class $B$ can access public data of class $A$
  3. C
    Member function of class $B$ cannot access private data of class $A$
  4. D
    Object of derived class $B$ can access public base class data
    Correct 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.