Files
2018-08-02 17:53:23 +01:00

48 lines
586 B
C++

class MyInt
{
public:
MyInt(int _value) : value(_value) {};
MyInt operator+(const MyInt &rhs)
{
return MyInt(value + rhs.value);
}
MyInt &operator+=(const MyInt &rhs)
{
value += rhs.value;
return *this;
}
MyInt &operator++() // ++x
{
value++;
return *this;
}
MyInt operator++(int) // x++
{
MyInt result(value);
value++;
return result;
}
MyInt &operator>>=(int amount)
{
value >>= amount;
return *this;
}
int value;
};
void test(MyInt a, MyInt b)
{
MyInt c = a + b;
c += b;
++c;
c++;
c >>= 4;
}