自增自减
来源:互联网 发布:安卓无忧软件 编辑:程序博客网 时间:2024/04/28 03:26
#include <iostream.h>
class Point //复数类
{
private:
int x,y;
public:
Point(int i=0, int j=0)//构造函数
{
x=i;
y=j;
}
void Show() //显示点值,格式:(x,y)
{
cout<<"("<<x<<","<<y<<")"<<endl;
}
Point operator ++(); //声明前置自增运算符“++”重载函数
Point operator ++(int); //声明后置自增运算符“++”重载函数(傻瓜式定义)
};
Point Point::operator ++() //定义前置自增运算符“++”重载函数
{
++x;
++y;
return *this;
}
Point Point::operator ++(int) //定义后置自增运算符“++”重载函数
{
Point ptold(x,y);
ptold.x=x++;
ptold.y=y++;
return ptold;
}
int main()
{
Point p1(20,40),p2;
p1.Show();
p2=p1++;
p1.Show();
p2.Show();
p2=++p1;
p1.Show();
p2.Show();
return 0;
}
class Point //复数类
{
private:
int x,y;
public:
Point(int i=0, int j=0)//构造函数
{
x=i;
y=j;
}
void Show() //显示点值,格式:(x,y)
{
cout<<"("<<x<<","<<y<<")"<<endl;
}
Point operator ++(); //声明前置自增运算符“++”重载函数
Point operator ++(int); //声明后置自增运算符“++”重载函数(傻瓜式定义)
};
Point Point::operator ++() //定义前置自增运算符“++”重载函数
{
++x;
++y;
return *this;
}
Point Point::operator ++(int) //定义后置自增运算符“++”重载函数
{
Point ptold(x,y);
ptold.x=x++;
ptold.y=y++;
return ptold;
}
int main()
{
Point p1(20,40),p2;
p1.Show();
p2=p1++;
p1.Show();
p2.Show();
p2=++p1;
p1.Show();
p2.Show();
return 0;
}
- 自增自减
- 自增自减
- 自增、自减
- 自增自减
- 自增自减
- 自增自减
- 自增/自减
- 自增自减问题
- java自增自减
- 4、自增自减
- 自增自减问题
- 自增、自减运算
- 自增自减运算
- C 自增自减
- 自增、自减运算
- 004 自增自减
- 自增/自减学习
- 自增“++”和自减“--”
- 近期总结
- Translation_java_Formatter
- 绘制和填充(Drawing and Filling)
- 算术表达式操作方法汇总
- oracle 基础及权限
- 自增自减
- Oracle 词语
- 云端的天使
- oracle sql的语句
- osg pick 是确定射线的方向向量
- PL/SQL 运算符
- QMIS项目文档管理系统发布
- 第二次作业参考答案
- A*算法入门