A friend function is a non-member function which can access the private and protected members of a class. To declare an external function as a friend of the class, the function prototype preceded with friend keyword should be included in that class. Syntax for creating a friend function is as follows: 1 2 3 4 5 6 class ClassName { ... friend return–type function–name(params–list); ... }; Following are the properties of a friend function: Friend function is a normal external function which is given special access to the private and protected members of a class. Friend functions cannot be
The post What are the use cases of friend functions and friend classes appeared first on Coding Security.
What are the use cases of friend functions and friend classes
read more
Tidak ada komentar:
Posting Komentar