The this pointer is not stored along the pointer to the element (special member pointers are a special case of this). If you just do
void (MyObject::*f)( int, int ) = &MyObject::method_that_takes_two_ints;
what is stored is simply the information that the member function must call on the object that you must later provide. If you want to call it, you need to pass an object where the compiler gets the this pointer.
MyObject o; (o.*f)(1, 2);
A member function pointer is only a member pointer whose type (which indicated) is a type of function. The standard states that member function pointers do not have their own βmember function typeβ that they point to, and which will somehow include this type of pointer.
int main() { typedef void fun() const; fun MyObject::*mem_function_ptr = &MyObject::const_method_that_takes_two_ints; }
fun in this code is a function type. A type that has a "normal" function. A pointer to a function, unlike a pointer to a member function, is simply a pointer to a function of this type:
void foo() { cout << "hello"; } int main() { typedef void fun(); fun * f = &foo; }
Whereas a pointer-member-function has an extra level-pointer at the top of this type of function.
Something about the this pointer and how it relates to the object it points to (not technical, but only theoretical material):
Each member function has a hidden parameter called an implicit object parameter , which is of type MyObject& or MyObject const& , depending on whether you have a const or nonconst function. The object on which you call the member function, o , is the implied object argument , which is passed to the parameter. In standard theory, which make up the rules that describe how member functions are called, the implicit object parameter is the first hidden parameter. This is conceptual and does not mean that this is a real case in implementation. Then, the implied argument of the object is bound to this implicit parameter of the object, which can lead to implicit conversions (therefore, if you call the const member function for an object that is not a constant, the qualification transformation is converted from MyObject to MyObject const& . Non-const function selects better, than const functions for calling, for a non-constant object). For example, in this code you can say:
struct A { operator int() const { return 0; } }; int main() { A a; int i = a;
That the implied argument of an object a type a bound to an implicit parameter of an object of type A const& , the object of which is pointed to by a pointer of this type A const* here. It is important to note that the parameter of an implicit object is only a theoretical construction in order to formalize how the rules are compiled for calling a member function (and the constructors do not include them), while this pointer actually exists. this is a pointer, because when this was introduced, C ++ has no references so far.
I hope this helps you figure it out.