のは、私は次のような定義があるとしましょう:C++ポインタでない関数ポインタ
class ScriptInterpreter {
public:
class cell;
typedef ScriptInterpreter::cell (ScriptInterpreter::*proc_t) (const std::vector<cell> &);
class cell {
public:
proc_t proc;
};
ScriptInterpreter::cell proc_add(const std::vector<cell> & c);
};
そして起こって次のコード:私は呼び出すしようラインで
ScriptInterpreter::eval(ScriptInterpreter::cell cell, environment * env)
{
// ...
ScriptInterpreter::cell c;
c.proc = &ScriptInterpreter::proc_add;
return (c.*proc_)(exps);
}
関数ポインタエラーが発生する
error: called object type 'proc_t' (aka 'ScriptInterpreter::cell (ScriptInterpreter::*)(const std::vector<cell> &)') is not
a function or function pointer
funcの前に*を追加すると、次のようになります。
ScriptInterpreter::cell c = (proc_cell.*proc_)(exps);
それは、この生成します
error: use of undeclared identifier 'proc_'
を私はすでにCallback functions in c++とその種類の他の問題を見て、何も本当に私に何が間違っているヒントを与えていないか、私のエラーに関する情報を提供しました。私は間違いなくそのような名前を何度も持っていません。 また、what is an undeclared identifier error and how do i fix itを読んだ後、私はすべてが大丈夫だと確信しています。
どうしたのですか?
編集:メンバー型へのポインタのポインタを通じてメンバ関数を呼び出すために実際のコードの代わりにプレースホルダーコード
まず、コードには 'B'がありません。 'A :: B'のみです。あなたの話題を理解できるように、あなたの 'main'に実際のコードを投稿する方が良いでしょう。 – AnT
'A'のメンバ関数へのポインタなので、それを呼び出すには' A'( 'B'ではなく)のオブジェクトが必要です。 – songyuanyao
BはAに属していません – Raindrop7