C++ の宿題について質問があります。私は*これについて混乱しています。
以下のコードは私が持っているものです。
私の質問は、= 演算子の if ステートメントの条件が真である理由は何ですか?
#include <cstring>
class abc {
char p[9];
int inc;
public:
abc( ) { inc = 8; strcpy(p, "10010101"); }
~abc( );
abc& operator=(const abc &);
};
abc::~abc( ) {
}
abc& abc::operator=(const abc &c) {
if(this != &c) { //my question is why this condition is true?
inc = c.inc - 2;
for(int i=0; i<inc; i++) {
p[i] = c.p[i] + 2;
}
}
return *this;
}
int main( ) {
abc x, y;
x = y;
return 0;
}