Code:
class ctemp
{
public:
typedef void (ctemp::*ttemp)(int);
ttempmptr;
ctemp()
{
mptr = &ctemp::func;
}
void func(int a)
{
printf("hehe %d\n", a);
}
void callit()
{
(this->*mptr)(0);
}
};
void main()
{
ctemptmp;
tmp.mptr = &ctemp::func;
(tmp.*mptr)(0);
tmp.callit();
}
When I try to compile it with gcc 3.4.3 it stops and says:
-"error: `mptr' undeclared (first use this function)" in the line with (tmp.*mptr)(0);
I've tried the same code in the visualc 7.1 and it compiled immediately...
Can someone help, I think that I've missed some command line switch, because I'm sure that is impossible gcc to lack such a standard feature...as member to pointer...
Any ideas will be appreciated... and sorry for the bad english...