1.

Which among the following is correct?(a) Friend function of derived class can access non-private members of base class(b) Friend function of base class can access derived class members(c) Friend function of derived class can access members of only derived class(d) Friend function can access private members of base class of a derived classThe question was asked in a national level competition.Origin of the question is Derived Class topic in portion Classes of Object Oriented Programming

Answer»

The correct option is (a) Friend function of derived class can access non-private members of base class

To EXPLAIN I would say: The friend function of a class can access the non-private members of base class. The reason behind is that the members of base class GETS derived into the derived class and hence BECOME members of derived class too. Hence a friend function can access all of those.



Discussion

No Comment Found

Related InterviewSolutions