Why does this code output 2.Isn't it illegal to declare the same function again.
Code:#include <stdio.h> void foo(); int main() { void foo(int); foo(1); return 0; } void foo(int i) { printf("2 "); }
Why does this code output 2.Isn't it illegal to declare the same function again.
Code:#include <stdio.h> void foo(); int main() { void foo(int); foo(1); return 0; } void foo(int i) { printf("2 "); }
No, it is illegal to define (effectively, to implement) the same function again. You can declare the same function as many times as you want, as long as the declarations are consistent with the definition.Originally Posted by narendrav
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)