Since C++11, using is generally more readable than typedef:
usingPointer=void(*)();
More generally, with C++11 and above, we now tend to use std::function instead of function pointers as they are able to hold more different types of functions, such as capturing lambdas. Example:
Since C++11,
using
is generally more readable thantypedef
:More generally, with C++11 and above, we now tend to use
std::function
instead of function pointers as they are able to hold more different types of functions, such as capturing lambdas. Example:Function pointers are still necessary to interface C++ and C codes.
Learned a lot from this comment. Thanks!!
Glad it helped : )
There is another use-case for
std::function
: it can be used to hold a "function object" (also called a "functor":