私の質問は、クラスを持つポインターとキーワード this に言及しています。
class class1 {
public:
bool isitme(class1& temp){
if(this == &temp)
return true;
else return false;
}
};
int main () {
class1 c3;
class1* c2 = &c3;
if(c3.isitme(*c2))
cout << "c3 == c2"; //it is returning that
system("pause");
}
上記のコードは機能していますが、私が理解していないのは、bool isitme(class1& temp)とif(this == &temp)が同じ関数にある場合にのみ機能する理由isitme()です。
つまり、クラス パラメータで tempのメモリ ブロックを既に読み取っており、class1& tempそのメモリ ブロックをキーワード と比較できるはずthisです。this == &temp参照 ( )を二重に取得した場合にのみ関数が真になるのはなぜですか?
ありがとう