Given a print function:
void print(int i)
{
cout << i << endl;
}
Why are we allowed to do this in the main function:
void (*bar)(int);
bar = &print;
But not this:
void fizz(int);
fizz = print;
But when it comes to function parameters, we can pass a pointer to a function or a copy of the function:
void foo(void (*f)(int))
{
(*f)(1);
}
void test(void f(int))
{
f(1);
}
Anyone know the reason for these differences?