How can I call a method given only its name?
- by mfolnovich
I'm trying to have method void run( string method ) which would run method in that class. For example:
class Foo {
public:
void run( string method ) {
// this method calls method *method* from this class
}
void bar() {
printf( "Function bar\n" );
}
void foo2() {
printf( "Function foo2\n" );
}
}
Foo foo;
int main( void ) {
foo.run( "bar" );
foo.run( "foo2" );
}
this would print:
Function bar
Function foo2
Thanks! :)