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 is xss and csrf?

515


How to check if a string contains a character or word in php?

533


How to find a substring from a given string in php?

501


What is difference between web service and api?

506


Which function can be used to exit from the script after displaying the error message?

507






Where php basically used?

554


What is php in simple words?

513


What is the use of imagetypes() method?

529


Explain mysql_error().

551


How can you execute php script from the command line?

543


Define soundex()?

505


What is a PHP Filter?

609


Does php support inheritance?

501


Which is better php or wordpress?

509


Is php deprecated?

524