++问题,急求大声解答
# include <iostream>
using namespace std;
class Coordinate
{
public:
Coordinate (int x,int y);
int getX ();
int getY ();
Coordinate operator++(int);
private:
int m_iX;
int m_iY;
};
Coordinate ::Coordinate (int x,int y)
{
m_iX=x;
m_iY=y;
}
int Coordinate ::getX()
{
return m_iX;
}
int Coordinate ::getY ()
{
return m_iY;
}
Coordinate Coordinate:: operator ++(int)
{
Coordinate old(*this);
m_iX++;
m_iY++;
return old;
}
int main ()
{
Coordinate c(1,3);
cout<<(c++).getX()<<" "<<(c++).getY()<<endl;
}
为什么m_iX输出结果是2,尔m_iY是三额