Track
オブジェクトを含む multimap メンバーを持つクラスがありNote
ます。Note
クラスのメソッドの1つはこれです:
float Note::getValue(){
float sample = generator->getSample(this); // not working
return sample;
}
Note
にも type のメンバーがあり、そのクラスのメソッドGenerator
を呼び出す必要があります。現在のオブジェクトを渡す必要があり、キーワードを使用してそうしようとしましたが、それが機能せず、エラーが発生しました。getSample
Note
Note
this
Non-const lvalue reference to type 'Note' cannot bind to a temporary of type 'Note *'
のメソッド定義はgetSample
次のようになります。
virtual float getSample(Note ¬e);
ご覧のとおり、このメソッドは非常に頻繁に呼び出され、オブジェクトをコピーする余裕がないため、参照を使用しています。だから私の質問は次のとおりです。これを行う方法はありますか? それとも、私のモデルを機能するものに変更しますか?
編集
私も使ってみたことを忘れていましたが、これもうまくいきgenerator->getSample(*this);
ませんでした。次のエラー メッセージが表示されます。
Undefined symbols for architecture i386:
"typeinfo for Generator", referenced from:
typeinfo for Synth in Synth.o
"vtable for Generator", referenced from:
Generator::Generator(Generator const&) in InstrumentGridViewController.o
Generator::Generator() in Synth.o
Generator::Generator(Generator const&) in InstrumentGridViewController.o
Generator::Generator() in Synth.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
これが私のGenerator
クラスの外観です (getSample メソッドはサブクラスに実装されています)。
class Generator{
public:
virtual float getSample(Note ¬e);
};