【发布时间】:2010-12-29 15:57:59
【问题描述】:
我正在尝试使用方法 void run( string method ),它将在该类中运行 method。例如:
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" );
}
这将打印:
Function bar
Function foo2
谢谢! :)
【问题讨论】:
-
你想完成什么?