Alex Vinokur said:
OK
Now is some problem with second parameter in foo2().
------ foo.cpp ------
void foo1 (int (i), int) {}
void foo2 (int (i), int()) {}
This declares a function, foo2, whose return type is void. It takes two
parameters -
- The first parameter is names, its type is an int
- The second parameter has NO NAME. It's type is pointer to function taking
nothing and returning int as parameter.
Probably what you are missing is that parentheses around a parameter name
are ignored (as is in the case in our first parameter), but parentheses
standing by themselves (as is in our second parameter), indicate the
existence of a parameter list. They indicate the presence of a parameter
that is
itself a pointer to a function.
int main()
{
foo1 (10, 20); // Line#5
foo2 (30, 40); // Line#6
return 0;
}
---------------------
------ Compilation ------
$ g++ foo.cpp
foo.cpp: In function `int main()':
foo.cpp:6: error: invalid conversion from `int' to `int (*)()'
The compiler error message should also give you the answer!
Hope that clears it.
-Sharad