That's why you can't define operator==(int, int). The reason why you can't
call operator==(10, 20) is different.
C++03 13.6 [over.built]/1:
"The candidate operator functions that represent the built-in operators
defined in clause 5 are specified in
this subclause. These candidate functions participate in the operator
overload resolution process as
described in 13.3.1.2 and are used for no other purpose. [Note: because
built-in operators take only
operands with non-class type, and operator overload resolution occurs only
when an operand expression
originally has class or enumeration type, operator overload resolution can
resolve to a built-in operator only
when an operand has a class type that has a user-defined conversion to a
non-class type appropriate for the
operator, or when an operand has an enumeration type that can be converted
to a type appropriate for the
operator."
STL
Post by Victor BazarovPost by Vladimir GrigorievMay I write operator ==( 10, 20 ) ?
No, the Standard explicitly prohibits overloading operators for built-in
types (Standard, [Expr]/3). Since 10 and 20 are of built-in type, int,
you can't define an operator that would potentially alter the behaviour of
the equality operator defined by the Standard.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask