本帖最后由 zds212 于 2021-5-7 22:33 编辑
[C++] 纯文本查看 复制代码 #include<iostream>
using namespace std;
class mint
{
friend ostream& operator<<(ostream& cout, mint p);
public:
mint()
{
number = 0;
}
mint& operator++()
{
number++;
return *this;
}
mint operator++(int)
{
mint temp=*this;
number++;
return temp;
}
private:
int number;
};
ostream& operator<<(ostream& cout,mint p)
{
cout << p.number;
return cout;
}
void text01()
{
mint p;
cout << ++(++(++p)) << endl;
cout << p++<<endl;
cout << p << endl;
}
int main()
{
text01();
system("pause");
return 0;
} |