CoolInterview.com - World's Largest Collection of Interview Questions
Send Free SMS
 Interview Questions  
 Our Services  


INTERVIEW QUESTIONS LANGUAGES C++ DETAILS
Question :
What is friend function?



Category C++ Interview Questions
Rating (5.0) By 2 users
Added on 7/19/2006
Views 2351
Rate it!
Answers:

A friend function is a non member function of a class, that is declared as a friend using the keyword "friend" inside the class. By declaring a function as a friend, all the access permissions are given to the function.



Friend function allows the functions of outside class to access the private data members and member functions of another class.It can be achieved by prefixing them with the keyword friend...



 Posted by: anu    

Contact anu  Contact anu

Friend function can also be used in operator overloading if the operator in applied on objects of the different class.
For example:

cout<<Number;

cout is in built object and Number is object of the user defined class.
To overload the operator "<<" we need to declare the operator function (operator<<) as friend function of the Number object calss.



 Posted by: mahendra.Kolluri    

Contact mahendra.Kolluri  Contact mahendra.Kolluri

A friend fuction like a global fuction with special previlage.And it will use when we need to work on objects two different classes.



 Posted by: Manish    

Contact Manish  Contact Manish


If you have the better answer, then send it to us. We will display your answer after the approval.
Name :*
Email Id :*
Answer :*
Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
Process Verification  Enter the above shown code:*
Inform me about updated answers to this question

   
Related Questions
View Answer
What is public, protected & private?


View Answer
What is polymorphism? Explain with an example?


View Answer
What is a class?


View Answer
What is the difference between structures and classes in C++?
View Answer
What is an object?


View Answer
What is the difference between class and structure?


View Answer
We can overload assignment operator as a normal function.But we can not overload assignment operator as friend function why?



View Answer
What are virtual functions?


View Answer
What is the Basic nature of "cin" and "cout" and what concept or principle we are using on those two?

View Answer
What is a scope resolution operator?


View Answer

Please Note: We keep on updating better answers to this site. Subscribe to our newsletter to get notified when better answer is posted.

Notify me when better answer is posted!
Email:

View ALL C++ Interview Questions

User Options
Sponsored Links


Copyright ©2003-2010 CoolInterview.com, All Rights Reserved.
Privacy Policy | Terms and Conditions
Page URL: http://www.coolinterview.com/interview/6150/default.asp?cachecommand=bypass


Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Free SMS | Dedicated Servers | Joke of the Day

0.69