Monday, April 07, 2008

C++ : pointer to member function

class Foo{
public:
int iVal;
int Bar(int);
};


int Foo::* pm;

is a pointer to a member variable that is an integer.

pm = &Foo::iVal;

is used to initailize a pointer to a member variable

Foo foo;

int i = foo.*pm

is used to retrieve values of the pointer to member variable

int (Foo::*pmf) (int) = &Foo::Bar;

is a pointer to member function that is initialized by the address of member function Bar

No comments: