Advertisement Remove all ads

What is Friend Function - Computer Science 1

What is Friend Function ?

Advertisement Remove all ads


(1) C++ allows the common function to be made friendly with more than one classes, there by allowing the function to have access to the private data of classes. Such a function need not be member of any of classes.
(2) Non-member function cannot have access to the private data of a class. However, there could be a situation where user would like two classes to share a particular function. At this situation friend
function is used.
(3) The keyword “friend” declares the function to be friendly with that class. This function is defined as a normal C++ function. The function definition does not use class-name, keyword friend or scope resolution operator.

Concept: C++ Programming
  Is there an error in this question or solution?
Advertisement Remove all ads


Advertisement Remove all ads
Advertisement Remove all ads

View all notifications

      Forgot password?
View in app×