What is the use of friend function?

Answer Posted / vijaya

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 ?    90 Yes 15 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the advantages of oops in php?

780


What does $this do in php?

746


Describe session in php.

757


How arrays are used in php?

796


What is api example?

762


What is php.ini & .htacess file?

787


What is cookies? How to create cookies in php?

729


Is php deprecated?

750


What are the options to transfer session ids?

847


Explain Type hinting in PHP?

813


What is php default argument?

753


Explain what does the expression exception::__tostring means?

698


How to create a web form?

785


How check field is empty or not in php?

816


How to get the http request in php?

802