//成员函数方式实现一元操作符重载
#include<iostream.h>
class temp
{
private:
int x,y;
public:
void operator ++();//++处应为C++存在的操作符
};
void temp::operator ++()
{
x++;
y++;
}
main()
{
int x=5;
int y=6;
int z;
z=++x;
cout << "x=5";
cout << " z=++x";
cout << "/n";
cout << "z=" << z;
cout << "而";
cout << " x=" << x;
cout << "/n";
cout << "/n";
z=++y;
cout << "y=6";
cout << " z=++y";
cout << "/n";
cout << " z=" << z;
cout << "而";
cout << "y=" << y;
cout <<"/n";
return 0;
}
#include<iostream.h>
class temp
{
private:
int x,y;
public:
void operator ++();//++处应为C++存在的操作符
};
void temp::operator ++()
{
x++;
y++;
}
main()
{
int x=5;
int y=6;
int z;
z=++x;
cout << "x=5";
cout << " z=++x";
cout << "/n";
cout << "z=" << z;
cout << "而";
cout << " x=" << x;
cout << "/n";
cout << "/n";
z=++y;
cout << "y=6";
cout << " z=++y";
cout << "/n";
cout << " z=" << z;
cout << "而";
cout << "y=" << y;
cout <<"/n";
return 0;
}