Function Pointer Parameters
Just as with arrays (§ 6.2.4, p. 214), we cannot define parameters of function type but can have a parameter that is a pointer to function. As with arrays, we can write a parameter that looks like a function type, but it will be treated as a pointer:
// third parameter is a function type and is automatically treated as a pointer to functionvoid useBigger(const string &s1, const string &s2, bool pf(const string &, const string &));// equivalent declaration: explicitly define the parameter as a pointer to functionvoid useBigger(const string &s1, const string &s2, bool (*pf)(const string &, const string &));
When we pass a function as an argument, we can do so directly. It will be automatically ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access