#include<iostream>
using namespace std;
class point
{
public:
point(int x,int y){};
void display()const;
point& operator++(){
++x;
++y;
return *this;
}
point& operator--(){
--x;
--y;
return *this;
}
void display()
{
cout<<"("<<x<<","<<y<<")"<<endl;
}
private:
int x;
int y;
};
int main(){
point c(5,6);
c.display();
cout<<"++c=";
++c;
c.display();
cout<<"--c=";
--c;
c.display();
return 0;
}
为什么输出的是地址!!!!
using namespace std;
class point
{
public:
point(int x,int y){};
void display()const;
point& operator++(){
++x;
++y;
return *this;
}
point& operator--(){
--x;
--y;
return *this;
}
void display()
{
cout<<"("<<x<<","<<y<<")"<<endl;
}
private:
int x;
int y;
};
int main(){
point c(5,6);
c.display();
cout<<"++c=";
++c;
c.display();
cout<<"--c=";
--c;
c.display();
return 0;
}
为什么输出的是地址!!!!