// class
class MyClass
{
public:
void doIt() const
{
cout << "It works!" << endl;
}
void(MyClass::*fPtr)() const;
};
// main
MyClass *t = new MyClass;
// store function address
t->fPtr = &MyClass::doIt;
(*(t->fPtr))(); // Whats wrong with this line?
fPtr に格納されている関数を呼び出すにはどうすればよいですか? 私が試したとき (*(t->fPtr))(); コンパイラはこれらのエラーを出します:
エラー C2171: '*': タイプ 'void (__thiscall MyClass::* )(void) const のオペランドは無効です
エラー C2064: 項は引数を 0 個取る関数として評価されません