Sequence of Argument Conversions

Argument-matching conversions occur in the following order:

  1. exact match in which the actual arguments match exactly (including a match with one or more trivial conversions) with the type an d number of formal arguments of one declaration of the overloaded function
  2. match with promotions in which a match is found when one or more of the actual arguments is promoted
  3. match with standard conversions in which a match is found when one or more of the actual arguments is converted by a standard con version
  4. match with user-defined conversions in which a match is found when one or more of the actual arguments is converted by a user-defined conversion
  5. match with ellipses

Match through promotion follows the rules for Integral Promotions and Standard Type Conversions.

You can override an exact match by using an explicit cast. In the following example, the second call to f() matches with f(void*):

void f(int);
void f(void*);
void main()
{
      f(0xaabb);            // matches f(int);
      f((void*) 0xaabb);    // matches f(void*)
}

The implicit first argument for a nonstatic member function or operator is the this pointer. It refers to the class object for which the member function is called. When you overload a nonstatic member function, the first implicit argument, the this pointer, is matched with the object or pointer used in the call to the member function. User-defined conversions are not applied in this type of argument matching for overloaded functions or operators.

When you call an overloaded member function of class X using the . (dot) or -> ( arrow) operator, the this pointer has type X* const. The type of the this pointer for a constant object is const X* const. The type of the this pointer for a volatile object is volatile X* const.



Argument Matching in Overloaded Functions
Trivial Conversions


User-Defined Conversions
The this Pointer
Overloading Functions
Overloading Operators
Dot Operator
Arrow Operator