1.

If public members are to be restricted from getting inherited from the subclass of the class containing that function, which alternative is best?(a) Make the function private(b) Use private inheritance(c) Use public inheritance(d) Use protected inheritanceI have been asked this question by my college director while I was bunking the class.I'd like to ask this question from Public Member Functions topic in division Member Functions & its Types of Object Oriented Programming

Answer»

Correct ANSWER is (B) Use private inheritance

The EXPLANATION is: If private inheritance is USED then the class CONTAINING the function will be able to use the function with rules of whichever specifier is used. Then the derived class makes those function the private members of itself. This restricts the public members of parent class from further inheritance.



Discussion

No Comment Found

Related InterviewSolutions