标签:code out color 思考 turn info ++ src 运算符
#include <iostream>
using namespace std;
class Imaginary{
public:
Imaginary():real(0), imag(0){
cout << "c:" << this << endl;
}
Imaginary(int real, int imag):real(real), imag(imag){
cout << "c:" << this << endl;
}
Imaginary operator+ (const Imaginary &m){
return Imaginary (real + m.real, imag + m.imag);
}
~Imaginary(){
cout << this << endl;
}
private:
int real;
int imag;
};
int main(){
Imaginary m1(10, 20);
Imaginary m2(1, 2);
Imaginary m3;
printf("m3 : %p\n",&m3);
m3 = m1 + m2;
cout << 1 << endl;
return 0;
}
执行结果:
标签:code out color 思考 turn info ++ src 运算符
原文地址:https://www.cnblogs.com/xiaoshiwang/p/9500880.html