Item 16. Pointers to Member Functions Are Not Pointers

When you take the address of a non-static member function, you don’t get an address; you get a pointer to member function.

image

The declaration syntax of a pointer to member function is really no more difficult than that of a pointer to a regular function (which, admittedly, is bad enough as it is; see Dealing with Function and Array Declarators [17, 61]). As with pointers to data members, all that’s necessary is to use classname::* rather than * to indicate that the function referred to is a member of classname. Unlike a regular pointer to function, though, a pointer to member function can refer ...

Get C++ Common Knowledge: Essential Intermediate Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.