It's a little perplexing.
Function type and pointer to function type are distinct kinds (no more similar than int and pointer to int).
However, in virtually all cases, a function type decays to a reference to a function type.
In this context, rotting roughly refers to conversion (there is a difference between type conversion and decaying, but you are probably not interested in it right now).
What matters is that practically every time you use a function type, you end up with a reference to the function type.
But take note of the nearly - almost every time is not always!
And there are rare circumstances where it does not.
typedef void(functionPtr)(int);
functionPtr fun = function;
This code tries to clone one function to another (not the pointer! the function!)
However, this is not feasible since functions in C++ cannot be copied.
The compiler does not let this, and I'm surprised you got it compiled (you say you got linker errors?)
Now for the code:
typedef void(functionPtr)(int);
functionPtr function;
function(5);
function does ...READ MORE
Jun 21, 2022
in C++
by
Damon
• 4,960 points
•
463 views