后置加加
#include <iostream>
using namespace std;
class points
{
private:
int x;
int y;
public:
points(int x, int y);
void display();
points operator++(int);
};
points::points(int x = 0, int y = 0) : x(x), y(y){};
void points::display()
{
cout << "x: " << this->x << "y: " << this->y;
};
points points::operator++(int)
{
points Old_object =*this;
this->x++;
this->y++;
return Old_object;
}
void test1(points &p1)
{
points p2=p1++;
p2.display();
}
int main()
{
points p1(22, 33);
test1(p1);
p1.display();
}