1 2 3 4 5 6 7 8 9 10 11 12 13 14 | int f(); int f(); //fine, matches int f(int); //different signature, fine float f(); //error: return type does not match class c; class c; //fine, matches struct c; //wrong: does not match extern int x; //syntactically fine, but completely evil extern int x; //syntactically still fine, but still completely evil extern float x; //syntactically wrong, and just as evil int main(){} |
aW50IGYoKTsKaW50IGYoKTsgLy9maW5lLCBtYXRjaGVzCmludCBmKGludCk7IC8vZGlmZmVyZW50IHNpZ25hdHVyZSwgZmluZQpmbG9hdCBmKCk7IC8vZXJyb3I6IHJldHVybiB0eXBlIGRvZXMgbm90IG1hdGNoCgpjbGFzcyBjOwpjbGFzcyBjOyAvL2ZpbmUsIG1hdGNoZXMKc3RydWN0IGM7IC8vd3Jvbmc6IGRvZXMgbm90IG1hdGNoCgpleHRlcm4gaW50IHg7IC8vc3ludGFjdGljYWxseSBmaW5lLCBidXQgY29tcGxldGVseSBldmlsCmV4dGVybiBpbnQgeDsgLy9zeW50YWN0aWNhbGx5IHN0aWxsIGZpbmUsIGJ1dCBzdGlsbCBjb21wbGV0ZWx5IGV2aWwKZXh0ZXJuIGZsb2F0IHg7IC8vc3ludGFjdGljYWxseSB3cm9uZywgYW5kIGp1c3QgYXMgZXZpbCAKCmludCBtYWluKCl7fQ==
prog.cpp:4:9: error: new declaration ‘float f()’ prog.cpp:2:5: error: ambiguates old declaration ‘int f()’ prog.cpp:12:14: error: conflicting declaration ‘float x’ prog.cpp:11:12: error: ‘x’ has a previous declaration as ‘int x’
-
result: Compilation error (maybe you wish to see an example for C++11)


