Reload & reload incremental and subtraction operators, differences between reload and rewriting
Class Rule {private: double m_Length; public: explicit Rule (double lg = 1.0): m_Length {lg }{} Rule & operator ++ (); const Rule operator ++ (int); Rule & operator -- (); const Rule & operator -- (int); void showRuleLength () {cout <"length: "<this-> m_Length <endl ;}}; inline Rule & Rule: operator ++ () {++ (this-> m_Length); return * this ;} inline const Rule: operator ++ (int) // returns a constant object. Changing {Rule rule {* this} is not allowed }; // use the copy constructor to create the object + + * this; // because the prefix ++ has overloaded return rule; // returns the copy of the object} inline Rule & Rule :: operator -- () {-- (this-> m_Length); return (* this);} inline const Rule & Rule: operator -- (int) {Rule rule (* this ); -- * this; return rule;} int main () {Rule a {4.0}; Rule B; B = a ++; B. showRuleLength ();}