Function call

How to call hh() by overloaded function call operator in the below case?

like in normal function call it's A a; a(), here it's supposed to return pointer to class function which is supposed to call by providing variable of type A and calling it as pointer-to-function.

class A
{
typedef void(A::*type2)();

public:
operator type2()
{
return &A::hh;
}

void hh()
{
}
};

It has no specific application in my case, just curiosity how the syntax should be to call it.
1
2
A a;
(a.*(void(A::*)())a)();

or equivalent static_cast.

Or this, for variety:
1
2
A a;
std::mem_fn<void(), A>(a)(a);
Last edited on
Thanks Sergey!
Topic archived. No new replies allowed.