Friend Function. Friend Function. Any data which is declared private inside a class is not accessible from outside the class . A non-member function cannot have an access to the private data of a class.
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
Any data which is declared private inside a class is not accessible from outside the class.
A non-member function cannot have an access to the private data of a class.
C++ support a special function to access private data of class called friend function or friendly fun.
A friend function is used to access private data in a class from outside the class.
A friend function is not a member of a class but has access to the class's private members.
To make a fun friend, the fun declaration should be preceded by the keyword friend
friend void show();// declaration
Void show() // definition
Friend fun def does not need the keyword and scope resolution opr (::)
Friend fun are not in the scope of any class, so they cannot invoked using class object.
They invoked like an ordinary functionin c language
A friend can be declared in any number of classes.