TITLE: The first argument to overloaded operators PROBLEM: hartman@ulogic.UUCP (Richard M. Hartman), 14 Oct 92 I would like some explanation of the reasoning behind the rule that an overloaded operator must take at least one parameter of as "class" type. RESPONSE: steve@taumet.com (Steve Clamage) Vice Chair, ANSI C++ Committee, X3J16 One explanation: Suppose we had int operator+(int, int); When you write "i+j" or "k+2", the result would depend on whether a prototype for that function were in scope. This would be the source of very subtle program bugs. The requirement that overloaded operators must have a class parameter means that an operator either has its predefined meaning or is illegal without a prototype. Operator "+" is not predefined for class types. The guideline, stated in the ARM, is that C++ is extensible, not mutable. Some operators have default semantics for classes. Those operators are further required to be members of a class for the above reason. For example, assignment is predefined for class types, so a user-defined assignment operator must be a member function.