C++随笔——操作符重载
操作符重载:
F& operator++(){n+=d;return *this;}//前加
F operator++(int){F old(*this);n+=d;return old;}//后加
friend F& operator--(F& f){f.n-=f.d;return f;}//前减
friend F operator--(F& f, int){F old(f);f.n-=f.d;return old;}//后减
operator double(){return 1.0*n/d;}//类型重载
operator bool(){return n!=0;}//类型重载