1.

Which of the following is correct about friend functions?(a) Friend functions use the dot operator to access members of a class using class objects(b) Friend functions can be private or public(c) Friend cannot access the members of the class directly(d) All of the mentionedThis question was posed to me during a job interview.The above asked question is from Friend Function topic in section Source Files, Classes and Operator Overloading in C++ of C++

Answer»

Correct option is (d) All of the mentioned

To EXPLAIN I would SAY: Friend function can be declared either in private or public PART of the class. A friend function cannot ACCESS the members of the class directly. They use the dot membership operator with a member name.



Discussion

No Comment Found

Related InterviewSolutions