/*program to show use of friend function operator overloading over normal
operator overloading using methods
a pro of using friend operator overloading instead of normal is that
we can use it to overload for simple datatypes like class obj and int datatype
which aint possible with normal operator overloading
*/
#include <iostream>
using namespace std;
class A
{
int num1;
public:
A() {}
A(int num1)
{
this->num1 = num1;
}
friend int operator+(A &, int);
};
int operator+(A &a, int num2)
{
return a.num1 + num2;
}
int main()
{
A a(2);
int num2 = 4;
cout << a + num2;
return 0;
}