hello, I don't understand why the code in line 14 doesn't work.
I want to make an array of functions so the user can choose at runtime what function to execute.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include <iostream>
usingnamespace std;
class foo
{
public:
void printf(){cout<<"hello world\n";}
};
int main()
{
void (foo::* px)(void) = {};
px = &foo::printf; //pointer to member function
foo *te = new foo;
te->*px(); //this doesn't work why???
//te->printf();//like this but with pointers ???
}
To keep it simple, i Started with one pointer, but it doesn't seem to work...
Please help...