I am trying to understand the C ++ function pointer syntax. In Eclipse on Linux, when you type:
void(*);
He flashed the expression with a syntax error message, but he allowed me to compile it and run the program. Then in Visual Studio I tried it and it wonβt compile saying "Expected Expression". However, what is strange when I do this:
std::vector<void(*)> myVector;
It compiles fine in Visual Studio. Also a couple of online compilers void (*); excellent on his own work. I know that:
void (*)();
... is a function pointer and ...
void();
... is the signature of the function, so you can:
std::function<void()> func;
I am having trouble understanding the syntax of a function pointer.
Thanks.
source share