Predict the output of following program.
(A) Compiler Error in show() because x is protected in class A
(B) Compiler Error in show() because y is private in class b
(C) The default value of A::x = 0 The default value of B::y = 0
(D) Compiler Dependent
Explanation: Please note that show() is a friend of class A, so there should not be any compiler error in accessing any member of A in show().
Class B is inherited from A, the important point to note here is friendship is not inherited. So show() doesn’t become a friend of B and therefore can’t access private members of B.
Quiz of this Question