What is friend function?

Showing Answers 1 - 4 of 4 Answers

samiksc

  • Jan 25th, 2006
 

A friend function is actually a friend declaration inside a class for an outside function. The intent is to allow the outside function to access all data of the class including private and protected data.

  Was this answer useful?  Yes

kavitha

  • Jul 26th, 2006
 

friend funtion is used to access to  protected and public data.

is denoted as:

this function defination is inside the class only.without using scoperesolution operator.

friend functionname(args)

{

-------//function defination

-------}

  Was this answer useful?  Yes

suganyayaso

  • Mar 13th, 2009
 

A friend function is used for accessing the non-public members of a class. A class can allow non-member functions and other classes to access its own private data, by making them friends. Thus, a friend function is an ordinary function or a member of another class.

  Was this answer useful?  Yes

Purbita Biswas

  • Oct 8th, 2011
 

A friend function is a function that is not a member of a class but has access to the private and protected members of the class. A friend declaration can be placed anywhere in the class declaration.
Syntax:-
class classname
{
private:
------
------
public:
member function declaration();
friend return type function name(argument list);
};

Code
  1. #include<iostream.h>

  2. #include<conio.h>

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions