I have the following program which I'd like to get it fixed. Not sure how to make it syntactically correct.
class A{
void f(){};
void (A::*)()get_f(){return &A::f;}
};
Also, I would like eventually move the function definition outline like the following.
void A::(*)()A::get_f(){
return &A::f;
}
What the correct syntax here too?
Thanks a lot for your help!
Like this:
class A{
void f(){};
void (A::*get_f())() {return &A::f;}
};
and similarly:
void (A::* A::get_f())(){
return &A::f;
}
See it in action on ideone. Note that using it is just the same as with typedef (in the other answers).
BTW, for extra points and vomit (ha, ha):
void (A::* (A::* get_get_f())())();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With