#include <iostream>
using namespace std;
class complex{
private:
int real,img;
public:
complex(int r=0,int i=0){
real=r;
img=i;
}
complex operator + (complex const &obj){
complex result;
result.img=img+obj.img;
result.real=real+obj.real;
return result;
}
void print()
{
cout<<real<<"+ i"<<img <<endl;
}
};
int main() {
complex c1(2,3),c2(3,4);
complex c3=c1+c2;
c3.print();
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: