TITLE: overloading of operators (Newsgroups: comp.std.c++, 12 Apr 98) LIU: "X. Liu" >I am wondering how standard restrict the overload of operators. It is >reasonable to forbid the operator overload to primitive types (for example >int operator + (int, int) ). However When I use VC++(5.0 plus sever pack 3), >I find VC++ even forbid the operators for pointers to class. CLAMAGE: clamage@Eng.Sun.COM (Steve Clamage) The compiler is correct. It was always the rule in C++ that at least one argument of an overloaded operator must be of a class type or a reference to a class type. (If the function is a class member function, that meets the requirement.) See the ARM, p 330. The draft standard relaxes the rule, and allows overloaded operators on enum (and reference to enum) types as well. Pointer types do not fulfill the requirements for arguments of overloaded operators. Reference: Draft standard 13.5 "Overloaded operators", paragraph 6.