Question 37Asked in UGC NET Computer Science, August 2016 (Paper II & III, Selected Questions)

If a function is friend of a class, which one of the following is wrong?

  1. AA function can only be declared a friend by a class itself
  2. BFriend functions are not members of a class, they are associated with it
  3. CFriend functions are members of a class
  4. DIt can have access to all members of the class, even private ones
Show answerHide answer

Correct answer: (C) Friend functions are members of a class

Explanation

A friend function of a class is defined outside that class's scope but has the right to access all private and protected members of the class. Even though the prototypes for friend functions appear in the class definition, friends are not member functions.

From UGC NET Computer Science PYQ, August 2016 (Paper II & III, Selected Questions)

This is question 37 of UGC NET Computer Science PYQ, August 2016 (Paper II & III, Selected Questions). See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.