#include <iostream>
using namespace std;
class ope
{
private: int real, imag;
public:
ope(int r, int i){
real=r;
imag=i;
}
ope operator + (ope const &obj) //operator overloading
{ ope temp;
temp.imag = imag + obj.imag;
temp.real = real + obj.real;
return temp;
}
void show()
{
cout << "Result : " << real << " + i" << imag << endl;//print complex numbers
}
};
int main()
{
ope f1(2,5) , f2(7,6);
ope f3 = f1+f2;
f3.show();
return 0;
}
I am new in programming and I tried to use operator overloading but I got this error can anyone help me? In this code, I am trying to print complex numbers using operator overloading.