Skip to content

Instantly share code, notes, and snippets.

@Plutor
Created October 24, 2012 19:05
Show Gist options
  • Save Plutor/3948158 to your computer and use it in GitHub Desktop.
Save Plutor/3948158 to your computer and use it in GitHub Desktop.
Colliding function names in C++
int foo() {
return 1;
}
char foo() {
return 'c';
}
int main() {
foo();
}
/*
$ g++ bad.cc
bad.cc: In function ‘char foo()’:
bad.cc:5:10: error: new declaration ‘char foo()’
bad.cc:1:5: error: ambiguates old declaration ‘int foo()’
*/
int foo(int x) {
return 1;
}
char foo(char x) {
return 'c';
}
int main() {
foo(7);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment