"One common mistake is to do this:"
"This would actually assign the return value from a call to function goo() to pFoo, which isn’t what we want. We want pFoo to be assigned to function goo, not the return value from goo(). So no parenthesis are needed."
- Alex from learncpp.com
So I tried to do this and got compiler error and this completely makes sense because I am trying to assign int value to int function pointer.
But Alex did not talk about any compiler error so what exactly he was trying to explain here. Can someone please explain?
Code
int foo()
{
}
int goo()
{
}
int main()
{
int (*pFoo)() = foo; // pFoo points to function foo()
pFoo = goo; // pFoo now points to function goo()
return 0;
}Code
1
pFoo = goo();"This would actually assign the return value from a call to function goo() to pFoo, which isn’t what we want. We want pFoo to be assigned to function goo, not the return value from goo(). So no parenthesis are needed."
- Alex from learncpp.com
So I tried to do this and got compiler error and this completely makes sense because I am trying to assign int value to int function pointer.
But Alex did not talk about any compiler error so what exactly he was trying to explain here. Can someone please explain?
"It is a simple logic truth that, short of mass emigration into space, with rockets taking off at the rate of several million per second, uncontrolled birth rates are bound to lead to horribly increased death rates."
- Richard Dawkins (The Selfish Gene)
- Richard Dawkins (The Selfish Gene)

