Created
October 24, 2012 19:05
-
-
Save Plutor/3948158 to your computer and use it in GitHub Desktop.
Colliding function names in C++
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()’ | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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