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

What is call by reference in php?

516


What is the use of @ in php?

553


Is uploaded file php?

541


Is php dying 2018?

550


Difference between $message vs. $$Message in php.

589






What is the scope of a variable defined outside a function?

546


Why do we use hooks?

508


Write a program to find the factorial of a number in php?

534


What does pear stand for?

542


What is the sign to start variables in PHP?

592


How to create a table to store files?

557


What is difference between strstr() and stristr() in PHP?

551


Can we override static method?

533


Is php a middleware?

519


What is dao in php?

475