1.

What is a friend function in C++?(a) A function which can access all the private, protected and public members of a class(b) A function which is not allowed to access any member of any class(c) A function which is allowed to access public and protected members of a class(d) A function which is allowed to access only public members of a classThis question was posed to me during an interview for a job.This interesting question is from Friend Function in section Source Files, Classes and Operator Overloading in C++ of C++

Answer»

The CORRECT answer is (a) A function which can access all the private, protected and public MEMBERS of a CLASS

To explain I WOULD say: FRIEND function in C++ is a function which can access all the private, protected and public members of a class.



Discussion

No Comment Found

Related InterviewSolutions