[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.
Technical Discussion :: C++

27 / 187

Explain about Friend function and friend class.

Answer:

Friend Function:
A friend function can access a class private data, even though it is not a member function of the class. This is useful when one function must have access to two or more unrelated classes and when an overloaded operator must use, on its left side, a value of a class other than one of which it is a member. Friends are also used to facilitate functional notation.

Friend Class:
It is possible to grant a non-member function access to the private members of a class by using a friend. A friend function has access to all private and protected members of the class for which it is a friend.

Asked In :: TCSCapgemini

Post Your Answer Here:


Rate This: +2 -0      +
Report    

Post Your Reply Here:

Alert me
q4i-reply-your-answer

Report Error

Please Login First Click Here

Most Popular Qs.