Wednesday, May 2, 2012

10.6

In C,


void f(int x, double y);
void f(int a, double);
void f(int, double z);
void f(int y, double q)
{ if (q> y) printf("ok!\n");
   else printf("not ok!\n");
}


would it be legal to include all of the declarations in the same code file? Explain.


No, it would not, straight C doesn't allow function overloading.  It wouldn't even be allowed in C++ because the function declarations are all of the same form( identical type, name, and order and number of variable types).

No comments:

Post a Comment