title=call of overloaded FUNCTION_NAME is ambiguous

Causes

edit

Arguments in a function call do not match those in any function declaration

edit

For example, a function, "foo", is called from inside main with an argument that is not a perfect match for any of the currently existing implementations of "foo".

void foo(int x);
void foo(double x);

int main () {
   long x = 5000;
   foo(x);
   ...

Solution 1: Cast the argument to match a declaration

int main () {
   long x = 5000;
   foo((int)x);

Solution 2: Create a new, overloaded version of the called function to match the arguments

void foo(int x);
void foo(double x);
void foo(long x);

int main () {
   long x = 5000;
   foo(x);

The same function is defined more than once

edit

Solution 1: Look for a misspelled or duplicate function definition/declaration

Solution 2: Make sure you're not using a function name defined in the standard library

template <typename T>
void swap(T &a, T &b) {  // error, "swap" is defined by the C++ standard library
   T tmp = a;
   a = b;
   b = tmp;
}

// Possible Fix
template <typename T>
void Swap(T &a, T &b) {  // Capitalized the first letter
   T tmp = a;
   a = b;
   b = tmp;
}

Notes

edit
  • Message found in GCC versions 3.2.3, 4.5.1