DEV Community

Lalit Kumar
Lalit Kumar

Posted on

operator overloading in c++ using friend function

Operator overloading provides an inherent interface to the users of our class, making it possible to work equally well with classes and built-in data types. Operator overloading in C++ allows operators to have user-defined meanings on user defined types.
This article will discuss overloading using friend functions.

There are three methods to do operator overloading in C++, they are

Overloading unary operators.
Overloading binary operator.
Overloading binary operator using a friend function.
And we are going to discuss only overloading binary operators using a friend function.

The function which has the right to access all private and protected members of the class but defined outside the scope of the class, is called friend function.

for more check the link given below

https://www.kodlogs.com/blog/2237/operator-overloading-in-c-using-friend-function

Top comments (0)