Original Post
Hi I was playing around with class member functions. Here is one sample straigh from the head just to show the idea. This is the way I have seen everyone is using member function pointers: My question is. Why should the typedef be used ? Why not just assign Big the function and use it later on ? Thanks for the help.
class MyClass
{
//possible code samples
void Sample1();
void Sample2();
//pointer typedef
typedef void (MyClass::*Big)();
//pointer to be used
Big big;
void Select(int ver)
{
//assign specific function
if( ver == 0)
{
big = &MyClass::Sample1();
}
else
{
big = &MyClass::Sample2();
}
//and call our pointer
(this->*big)();
}
};