编辑代码

#include <iostream>
using namespace std;
class MyInteger(){
    friend ostream& operator<<(ostream& cout,MyInteger& myInt);
public:
    MyInteger(){
        m_Num=2;
    }
    //前置--的重载
    MyInteger& operator--(){
        this->m_Num--;
        return *this;
    }
    //后置--的重载
    MyInteger operator--(int){
        MyInteger tmp=*this;
        this->m_Num--;
        return tmp;
    }
private:   
    int m_Num;
};
ostream& operator<<(ostream& cout,MyInteger& myInt){
    cout<<myInt.m_Num;
    return cout;
}
void test01(){
    MyInteger myInt;
    cout<<--myInt<<endl;
    cout<<myInt--<<endl;
}
int main() {
    //JSRUN引擎2.0,支持多达30种语言在线运行,全仿真在线交互输入输出。 
	//cout << "Hello JSRUN!   \n\n         - from C++ ." << endl;
    test01();
	return 0;
}