M
Maximus
I need to store a member function pointer as a class member, code below:
struct Struct_Type
{
typedef int (Struct_Type::*FuncType)(int, int);
FuncType funcA;
int func1(int a, int b) { return a+b+c;}
int func2(int a, int b) { return a-b+c; }
int func3(int a, int b) { return a*b+c; }
int c;
};
//Struct_Type value1 = {0, 1 };
Struct_Type value2;
//FuncType funcA = &Struct_Type::func2;
Struct_Type value = {NULL, 10 };
Struct_Type value3 = {&Struct_Type::func3, 100 };
However, when I invoked the member, the compiler (VS 2005) gave me an error:
std::cout << (value3.*funcA)(20, 10);
error C2065: 'funcA' : undeclared identifier
Thanx in advance.
struct Struct_Type
{
typedef int (Struct_Type::*FuncType)(int, int);
FuncType funcA;
int func1(int a, int b) { return a+b+c;}
int func2(int a, int b) { return a-b+c; }
int func3(int a, int b) { return a*b+c; }
int c;
};
//Struct_Type value1 = {0, 1 };
Struct_Type value2;
//FuncType funcA = &Struct_Type::func2;
Struct_Type value = {NULL, 10 };
Struct_Type value3 = {&Struct_Type::func3, 100 };
However, when I invoked the member, the compiler (VS 2005) gave me an error:
std::cout << (value3.*funcA)(20, 10);
error C2065: 'funcA' : undeclared identifier
Thanx in advance.