#include <iostream>
using namespace std;
class num{
int real;
int visial;
public:
num(){};
num(int real,int visial):real(real),visial(visial){};
num(const num &other):real(other.real),visial(other.visial){};
num(num &&other){
real=other.real;
visial=other.visial;
other.real=0;
other.visial=0;
};
num& operator++(){
this->real++;
this->visial++;
return *this;
}
num operator++(int){
num temp;
temp.real=this->real++;
temp.visial=this->visial++;
return temp;
}
num& operator--(){
this->real--;
this->visial--;
return *this;
}
num operator--(int){
num temp;
temp.real=this->real--;
temp.visial=this->visial--;
return temp;
}
};
c++ day4
最新推荐文章于 2024-07-24 20:55:30 发布
文章详细描述了一个名为num的C++类,包含构造函数以及重载了加法和减法操作符,展示了面向对象编程中的基本操作。
摘要由CSDN通过智能技术生成