What does this below line means.

In the function declarations, the argument identifiers are optional. In the definitions, they are required (the identifiers are required only in C, not C++).

This above line is from the book Bruce Eckel.

It says identifiers are required only in C, not in C++. But I thought Other wise.

///////////////////////////////////////
like in C

int foo();

int main() {
return 0;
}

int foo(int a, float b) {

return a;
}

is OK

////// but in C++ it is not and anything that is

int foo(); is equal to int foo(void);

AM I right?? If so the statement is confusing.

Thanks for your help.
Ok essentially it means that the specific names of the local variables used in the function are not needed, in a function declaration.

Say I wanted to make a function called blah. First we declare it:

int blah(int, int);

So we know that one of the parameters is of type int and that another is of type int, but we don't know what the function variable names are, local variable names.

The function definition:

int blah (int bleh, int lawl) {int lol = 0; lol = bleh*lawl; return lol;}

Here the local variables of the function (bleh and lawl) HAVE to be named, but in the declaration you don't have to. I think.
Topic archived. No new replies allowed.