What is a friend function in C++?
- A function that always returns a friend object.
- A private function of a class.
- A function that can access private members of a class.
- A function that can only be called within its class.
A friend function in C++ is a special function that, although not a member of a class, has access to its private and protected members. This is used to allow non-member functions and other classes to access such members.
Loading...
Related Quiz
- Which operator will give the remainder of a division operation?
- What is the primary difference between direct and indirect recursion?
- When might using a table of function pointers be preferable over a switch-case statement for handling various cases/conditions?
- Which type of class inheritance allows a derived class to inherit attributes and methods from more than one base class?
- In what scenario might a program have a memory leak due to an exception being thrown?