📄 lab8_1.cpp
字号:
// lab8_1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "iostream.h"
class Point
{
public:
Point(int x=0,int y=0)
{_x=x;_y=y;}
operator ++();
operator ++(int);
operator --();
operator --(int);
void display();
private:
int _x, _y;
};
void Point::display()
{
cout<<"_x="<<_x<<","<<"_y="<<_y<<endl;
}
Point::operator ++()
{
return ++_x;
return ++_y;
}
Point::operator ++(int)
{
return _x++;
return _y++;
}
Point::operator --()
{
return --_x;
return --_y;
}
Point::operator --(int)
{
return _x--;
return _y--;
}
void main()
{
Point p(2,2);
++p;
p.display();
p++;
p.display();
--p;
p.display();
p--;
p.display();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -