[Cs3] default parameter values
Mikhail Nesterenko
mikhail at cs.kent.edu
Sun Feb 25 12:16:42 EST 2024
CS3 students,
There was a question about default parameter values and function
pointers. So the answer is that the default parameter value is not
part of the function signature and function pointer is not allowed to
have default parameter values in any shape or form:
Here is an example code:
-----------
int f(int = 0);
int (*p1)(int) = f;
// int (*p2)() = f; // error: type mismatch
int main() {
int j = f(1);
int k = f(); // OK, means f(0)
p1(1);
// p1();// error: too few arguments
}
-----------
And more details:
https://stackoverflow.com/questions/2576411/function-pointers-with-default-parameters-in-c
Thanks,
--
Mikhail
More information about the cs3
mailing list