What are the Friend functions?

Friend functions are useful in accessing the data declared in private section of the class. The data declared in private section of class is accessible to only the member functions of class but not to the non-member functions of class. If any non member function tries to access that data compiler will give an inaccessible error. In order to use that private data, friend functions are used. Friend functions can access the private or protected data of Class. A friend keyword is used to make a function as a friend of class.

Syntax:
Function return_type function_name(class object);

More Questions

Leave a Reply

Word Verfication * Time limit is exhausted. Please reload CAPTCHA.