//Arithmetic operation using Binary Operator Overloading
#include<iostream>
using namespace std;
class BinaryArithmetic
{
private:
float num;
public:
void getnumber()
{
num = 10;
}
BinaryArithmetic operator+(BinaryArithmetic &ab)
{
BinaryArithmetic x;
x.num = num + ab.num;
return x;
}
BinaryArithmetic operator-(BinaryArithmetic &ab)
{
BinaryArithmetic x;
x.num = num - ab.num;
return x;
}
BinaryArithmetic operator*(BinaryArithmetic &ab)
{
BinaryArithmetic x;
x.num = num * ab.num;
return x;
}
BinaryArithmetic operator/(BinaryArithmetic &ab)
{
BinaryArithmetic x;
x.num = num/ab.num;
return x;
}
void show()
{
cout<<num;
}
};
int main()
{
BinaryArithmetic ba1,ba2,ba3;
ba1.getnumber();
ba2.getnumber();
ba3 = ba1 + ba2;
cout<<"Addition : ";
ba3.show();
ba3 = ba1 - ba2;
cout<<"\n\n Subtraction : ";
ba3.show();
ba3 = ba1 * ba2;
cout<<"\n\n Multiplication : ";
ba3.show();
ba3 = ba1/ba2;
cout<<"\n\n Division : ";
ba3.show();
return 0;
}