What is the use of friend function?

Answer Posted / cs thakur

Sometimes a function is best shared among a number of
different classes. Such functions can be declared either as
member functions of one class or as global functions. In
either case they can be set to be friends of other classes,
by using a friend specifier in the class that is admitting
them. Such functions can use all attributes of the class
which names them as a friend, as if they were themselves
members of that class. A friend declaration is essentially a
prototype for a member function, but instead of requiring an
implementation with the name of that class
attached by the double colon syntax, a global function or
member function of another class provides the match.

Is This Answer Correct ?    9 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to create reusable code in php?

556


What are the functions of string?

537


How do you use bcrypt for hashing passwords in php?

541


Tell me what types of loops exist in php?

578


When is a conditional statement ended with an endif?

532






What is the best php version for wordpress?

534


What is difference between single quotes and double quotes in php?

497


Tell me what are the functions to be used to get the image's properties (size, width and height)?

553


Is laravel an oop?

515


What PHP stands for?

574


How can you compare objects in php?

515


How do you put a space in html?

520


How to close a session properly?

543


How to convert strings to numbers in php?

566


What is $_ server request_method == post?

544