Member Function Pointer...
Say i have a member function pointer
Code:
class MyClass {
private:
typedef void (MyClass::*MyFunct)(const string&);
MyFunct f;
public :
void GeneralFunct(const string& s);
}
.....
{
MyFunct f = &MyClass::GeneralFunct;
this->*f("Hello There");
/* OR */
MyClass *class1;
class1->*f("Hello There");
/* OR */
MyClass class2;
class2.*f("Hello There");
}
Assuming what i've done is correct, why do i always need a Class Pointer to invoke a member function pointer?
Why can't i just ...
Code:
MyClass myclass = &MyClass::GeneralFunct;
myclass.f("What's wrong with this?");