c++关于重载++运算符
噢噢噢噢 2010-11-05 04:27:47 #include<iostream>
using namespace std;
class Complex
{
private:
double real,image;
public:
Complex(double r=0,double i=0):real(r),image(i){}
void Show() const
{
cout<<real<<" + "<<image<<"i"<<endl;
}
Complex operator--()
{
real=--real;
image=--image;
return *this;
}
Complex operator--(int)
{
Complex temp=*this;
real=--real;
image=--image;
return temp;
}
};
void main()
{
Complex C1(1,2),C2(3,4),C3,C4;
C3=C1--;
C4=--C2;
cout<<"C3 is "<<endl;
C3.Show();
cout<<"C4 is "<<endl;
C4.Show();
}
谁能说下 系统怎样识别 是调用前置-- 还是调用后置--??
刚学c++,被这个弄晕了