实现左移和递增运算符重载
#include <iostream>
using namespace std;
class MyInteger
{
friend ostream& operator<<(ostream& cout, MyInteger myInt);
public:
MyInteger(int value)
{
this->m_Num = value;
}
MyInteger& operator++()
{
++m_Num;
return *this;
}
private:
int m_Num;
};
ostream& operator<<(ostream& cout, MyInteger myInt)
{
cout << myInt.m_Num;
return cout;
}
void test()
{
MyInteger p1(10);
cout << ++(++p1) << endl;
cout << p1 << endl;
}
int main()
{
test();
system("pause");
return 0;
}