笔记本内存不够了,上课写的代码放到csdn上就把源文件删了,写的不好。可喷
#include <iostream>
using namespace std;
class CComplex {
private:
double real, image;
public:
CComplex(double r, double i) {
real = r;
image = i;
}
CComplex operator-(CComplex &a) {
CComplex temp(*this);
this->image -= a.image;
this->real -= a.real;
return *this;
}
CComplex &operator--() {
--real;
return *this;
}
void Output() {
cout << real << '+' << image << "i" << endl;
}
};
int main() {
CComplex c1(2, 3), c2(3, 4);
CComplex c3 = c1 - c2;
c3.Output();
}