1.

What are friend member functions (C++)?(a) Member function which can access all the members of a class(b) Member function which can modify any data of a class(c) Member function which doesn’t have access to private members(d) Non-member functions which have access to all the members (including private) of a classI had been asked this question in a job interview.Origin of the question is Types of Member Functions in section Member Functions & its Types of Object Oriented Programming

Answer»

The correct choice is (d) Non-MEMBER FUNCTIONS which have access to all the members (including private) of a class

The best explanation: A non-member function of a class which can access even the private data of a class is a FRIEND function. It is an EXCEPTION on access to private members outside the class. It is sometimes CONSIDERED as a member functions since it has all the access that a member function in general have.



Discussion

No Comment Found

Related InterviewSolutions