C++ Comparing Member Function Pointers-Collection of common programming errors

Member function pointers are not actual pointers. You should look at them as opaque structs. What does a method pointer contain:

 struct method_pointer {
     bool method_is_virtual;
     union {
         unsigned vtable_offset; // for a virtual function, need the vtable entry
         void* function_pointer; // otherwise need the pointer to the concrete method
     }
 };

If you could cast this to void* (you can’t) all you would have is a pointer the the struct, not a pointer to code. That’s why operator

Originally posted 2013-11-09 23:20:00.