Subscribe For Free Updates!

We'll not spam mate! We promise.

Apr 14, 2013

How can I handle easily a pointer to a method?



How can I handle easily a pointer to a method?

If you use templates, you won't have to write the annoying type of a pointer to a method (at the 'cost' of using a template). You can also use typedef to declare the type.

struct A
{
void m() {}
};
template
void f(A &a
8
PMETHOD pm)
{
(a.*pm)()
}
void function()
{
A a;
f(a, &A::m);
}

TechniqZone Socializer Widget
SOCIALIZE IT →
FOLLOW US →
SHARE IT →

0 comments:

Post a Comment