AFAIK, in C++, invoking another member function within a member of function of the same class should not require the "this" prefix as it is implicit. However, in the specific case of using function pointers, the compiler requires it. The following code compiles correctly only if I include the "this" prefix for the call via func pointer -
When function pointers are used can the compiler deduce when it points a member func of the same class?
class FooBar { private: int foo; public: FooBar() { foo = 100; } int GetDiff(int bar) { return abs(foo - bar); } typedef int(FooBar::*MyFuncPtr)(int); void FooBar::Bar() { MyFuncPtr f = &FooBar::GetDiff; (this->*f)(10); GetDiff(10); } };