Intro: I'm coding in VS2010 basic calculator based on FSM patter. So, I need action map.
How correctly initialize a static two dimensional array of pointers to functions in C++? I've already tried
static void (*action_map[])() = {A, pA}; //one dimension for example
or
static void (*action_map[])() = {&A, &pA};
and many others doesn't work.
ADDED
Everything should be done inside class. Example below doesn't work for me
public class A {
public:
void func1() { cout << "func1\n"; }
void func2() { cout << "func2\n"; }
void func3() { cout << "func3\n"; }
void func4() { cout << "func4\n"; }
typedef void (*function_t)();
function_t function_array[2][2];
A();
};
A::A()
{
function_array[2][2] = { { func1, func2}, { func3, func4 } };
};
int main(array<System::String ^> ^args)
{
A * tst = new A();
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 2; j++)
{
tst->function_array[i][j]();
}
}
return 0;
}
Please point what exactly I did wrong.
AandpA?