Multiple choice

What is the name of the non-member function that can access all the private and protected members of a class?

  1. Virtual functions

  2. Static functions

  3. Friend functions

  4. Constructors

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Friend functions are non-member functions which can access all the private and protected members of the class. An example of a friend function is class abc{ private: int f,s; public: friend int sum(abc x);}; Here, sum function can access even private members of class and is defined below -:int sum(abc x){return x.f+x.s;}.