Is there a way to dereference a member function pointer without using this?
Code:class Obj { private: void (Obj::*fp[3])(void); ...... }; void Obj::foo() { if(fp[0] != NULL) (this->*fp[0])(); }
This is a discussion on Member function pointer within the class within the C++ Programming forums, part of the General Programming Boards category; Is there a way to dereference a member function pointer without using this ? Code: class Obj { private: void ...
Is there a way to dereference a member function pointer without using this?
Code:class Obj { private: void (Obj::*fp[3])(void); ...... }; void Obj::foo() { if(fp[0] != NULL) (this->*fp[0])(); }
To dereference a pointer to member function, you must have an object to call it on. If you don't use this then you'll need to do something else to get the object, such as pass it to foo.
My best code is written with the delete key.