Are pointers to non-static member function “formally” not considered pointers

The quoted statements in question seems to be validated by the following statements from the standard. From dcl.mptr#3’s note: [ Note: See also [expr.unary] and [expr.mptr.oper]. The type “pointer to member” is distinct from the type “pointer”, that is, a pointer to member is declared only by the pointer to member declarator syntax, and never by … Read more

How Can I Pass a Member Function to a Function Pointer?

You can’t. You either pass a pointer to a static method or Parent has to accept also a pointer to the object. You might want to look at boost::bind and boost::function for that: #include <boost/bind.hpp> #include <boost/function.hpp> struct Y { void say(void) { std::cout << “hallo!”;} boost::function<void()> getFunc() { return boost::bind(&Y::say, this); } }; struct … Read more

Print address of virtual member function

Currently there is no standard way of doing this in C++ although the information must be available somewhere. Otherwise, how could the program call the function? However, GCC provides an extension that allows us to retrieve the address of a virtual function: void (A::*mfp)() = &A::func; printf(“address: %p”, (void*)(b->*mfp)); …assuming the member function has the … Read more