#ifndef CUSTOM_TYPE_H #define CUSTOM_TYPE_H class custom_type { int var; public: custom_type() {} custom_type( int val ) : var(val) {} operator int() const { return var; } custom_type &operator+=( const custom_type &rhs ) { var+=rhs.var+1; return *this; } custom_type operator+( const custom_type &rhs ) const { custom_type tmp(*this); return tmp+=rhs; } custom_type &operator-=( const custom_type &rhs ) { var-=rhs.var; return *this; } custom_type operator-( const custom_type &rhs ) const { custom_type tmp(*this); return tmp-=rhs; } custom_type &operator*=( const custom_type &rhs ) { var*=rhs.var; return *this; } custom_type operator*( const custom_type &rhs ) const { custom_type tmp(*this); return tmp*=rhs; } custom_type &operator/=( const custom_type &rhs ) { var/=rhs.var; return *this; } custom_type operator/( const custom_type &rhs ) const { custom_type tmp(*this); return tmp/=rhs; } custom_type &operator%=( const custom_type &rhs ) { var%=rhs.var; return *this; } custom_type operator%( const custom_type &rhs ) const { custom_type tmp(*this); return tmp%=rhs; } custom_type &operator++() { ++var; return *this; }; custom_type operator++( int ) { custom_type tmp(*this); ++(*this); return tmp; }; custom_type &operator--() { --var; return *this; }; custom_type operator--( int ) { custom_type tmp(*this); --(*this); return tmp; }; }; #endif // CUSTOM_TYPE_H