#include <iostream>
using namespace std;
class test {
private:
int x;
int y;
public:
test(int xx = 0, int yy = 0)
{
x = xx;
y = yy;
};
test operator- (void)
{
this->x = -this->x;
this->y = -this->y;
return *this;
};
void show(void)
{
cout<<"x = "<<x<<endl;
cout<<"y = "<<y<<endl;
}
};
int main(int argc, char * argv[])
{
test a(1, 1);
a = -a;
a.show();
system("pause");
return 0;
}
蛋疼的写下来。。
怎么样重载负号。。