Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

GCC Debugging/g++/Errors/call of overloaded function is ambiguous

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Causes Arguments in a function call do not match those in any function declaration 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 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 Message found in GCC versions 3.2.3, 4.5.1