Which of the following function declaration is illegal? WHY ???

Which of the following function declaration is illegal? WHY ???
a)

double func();
int main(){}
double func(){}
b)

double func(){};
int main(){}
c)

int main()
{
double func();
}
double func(){//statements}
d) None of the mentioned
What are your thoughts about the question?

"Yes".
the compiler will tell you, if you really do not know. Set up a little test program, and see which one breaks it.
c) has an unmatched {

:)
Last edited on
@Ganado, darn those comments!

a & b are also illegal, the custom function violates the return contract. :)
If an ill-formed function exists, but no one is around to call it, is it still undefined behavior?

Edit: Apparently the answer my half-facetious question is 'no', it's only undefined behavior if control flow reaches the illegal point.
n4659 9.6.3
Flowing off the end of a constructor, a destructor, or a function with a cv void return type is
equivalent to a return with no operand. Otherwise, flowing off the end of a function other than main (6.6.1)
results in undefined behavior.
Last edited on
An ill-formed function simply causes the program to be rejected by the compiler. ;-)
I should be more careful with my standardese :)
Last edited on
Topic archived. No new replies allowed.