What are the basic rules and idioms for operator overloading?
问题 Note: The answers were given in a specific order , but since many users sort answers according to votes, rather than the time they were given, here's an index of the answers in the order in which they make most sense: The General Syntax of operator overloading in C++ The Three Basic Rules of Operator Overloading in C++ The Decision between Member and Non-member Common operators to overload Assignment Operator Input and Output Operators Function call operator Comparison operators Arithmetic