Lecture overview -- Keyboard shortcut: 'u'  Previous page: Explicit type conversion -- Keyboard shortcut: 'p'  Next page: Function Overloading - more detailed rules -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Help page about these notes  Alphabetic index  Course home  Lecture 2 - Page 25 : 42
Notes about C++
Basic facilities
Function Overloading

Functions can be overloaded in C++

  • The C++ Programming Language: Page 149-153
 

  • Function overloading

    • Several function definitions with the same name, but different formal parameters

    • For a given function call, f(a1, ..., an), the types of the actual parameters are used to select a single best match among the overloaded function definitions

      • If no single best match can be found, an ambiguity is reported

      • Overload resolution is a compile time issue

      • Overload resolution does not affect the run time characteristic of the program

    • The function return types do not take part in overload resolution

  • Finding the best match

    • Pairs of actual and formal parameters are compared - details on the next page

    • A function that is the best match for one argument and a better than or equal match for all other arguments is called (§7.4.4)

      • The call is ambiguous if no such function exists