1.

When are friend functions used? Write syntax for declaration of friend function.

Answer»

A friend function is useful when a function to be shared between the two classes by
making a function as a friend to both the classes, thereby allowing a function to access private and protected data members of both classes.

syntax for declaration of friend function:
class classname {
public:
friend returntype function name (arguments);
}



Discussion

No Comment Found