Method Pointers
C++ is object-oriented, so classes can have methods. Non-static member functions (instance methods) have an implicit parameter (the this pointer) which is the pointer to the object it is operating on, so the type of the object must be included as part of the type of the function pointer. The method is then used on an object of that class by using one of the "pointer-to-member" operators: .*
or ->*
(for an object or a pointer to object, respectively).
Although function pointers in C and C++ can be implemented as simple addresses, so that typically sizeof(Fx)==sizeof(void *)
, member pointers in C++ are often implemented as "fat pointers", typically two or three times the size of a simple function pointer, in order to deal with virtual inheritance.
Read more about this topic: Function Pointer
Famous quotes containing the word method:
“Relying on any one disciplinary approachtime-out, negotiation, tough love, the star systemputs the parenting team at risk. Why? Because children adapt to any method very quickly; todays effective technique becomes tomorrows worn dance.”
—Ron Taffel (20th century)