Reputation: 1079
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);
Upvotes: 0
Views: 154
Reputation: 206689
I think you're looking for this tasty syntax:
((tablita).*(tablita.punterofunc))(num,0);
tablita.punterofunc
is a member function pointer. The general syntax for calling a pointer-to-member-function p
on an object o
is:
((o).*(p))(args...);
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.)
Upvotes: 6