#include <iostream>
using namespace std;
class CComplex
{
public:
CComplex()
{
real = 0;
imag = 0;
}
CComplex(int x,int y)// 1
{
real = x;
imag = y;
}
int real;
int imag;
CComplex operator + (CComplex obj1)
{
CComplex obj2(real + obj1.real, imag + obj1.imag);// 2
return obj2;
}
};
int main()
{
CComplex obj1(100,30); // 3
CComplex obj2(20, 30);
CComplex obj;
obj = obj1+obj2;
cout << obj.real <<endl;
cout << obj.imag << endl;
}
习惯受伤
相关分类