operator++(p1); //自己写的递增运算符重载

//递增运算符重载

#include
using namespace std;

class p
{
public:
int a;
int b;
};

p operator++(p& p1)
{
p temp;
temp.a = p1.a++;
temp.b = p1.b++;
return temp;
}

void z()
{
p p1;
p1.a = 10;
p1.b = 15;
operator++(p1); //自己写的递增运算符重载
cout << p1.a << endl;
cout << p1.b << endl;

}

int main()
{
z();
system(“pause”);
}

猜你喜欢

转载自blog.csdn.net/ADADQDQQ/article/details/108279521