isInstruction()
私のコード(私のものではない)には、問題なくメンバーを設定および取得するために使用される関数があります。今、私は同様の目的のために私自身の関数を追加しましたstate()
。このような:
struct foo {
bool & isInstruction() {
return isInst; // no problem
}
int & state() {
return state; //ERROR
}
private:
bool isInst;
int state;
};
最初の機能は問題ありません。しかし、2つ目は、
error: invalid initialization of reference of type ‘int&’ from expression of type
‘<unresolved overloaded function type>’
次に、これら2つの機能の違いは何ですか。私は何かが足りないのですか?