To find largest of three numbers using friend function



Use of friend functions should be done only in unavoidable circumstances ad not as a general practice.



 class biggest



          int a,b,c,large;


          void getdata();

friend int big(biggest abc);


 void biggest::getdata()


     cout<<"Enter any three number"<<endl;



 int big(biggest abc)












     cout<<" Biggest  no answer is.........="<<abc.large;

     return 0;


int main()


     class biggest obj;





    return 0;



A friend function to a class may be declared or defined within the scope of class definition. The general syntax of a friend function declaration is given below;

friend return_type user_define_name(arguments list)

In above syntax friend is a keyword which informs the compiler that it is not member function of the class.

Return_type is the type of the value that the function returns.

User_define_name is the name of the function defined by the user,arguments list is the set of parameters defined inside the parenthesis.


largest of three numbers using friend function