In my class Tabla I have a public pointer to method:
public:
int (Tabla :: *punterofunc)(int,int);
In main I point it to a class method:
tablita.punterofunc = &Tabla :: in_lineal;
But this call doesn’t work!
tablita->punterofunc(num,0);
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I think you’re looking for this tasty syntax:
tablita.punterofuncis a member function pointer. The general syntax for calling a pointer-to-member-functionpon an objectois:Just apply that to your code. (Some of the parens might not be necessary in all cases (not sure), but if you stick with that, it should work all the time.)