그것은, 할당 연산자 Object& operator=(const Object& rhs)
트랜스퍼 연산자 Object& operator=(Object& rhs)
수있다. 아주 쓸모없는 것조차. 그러나 그들 중 누구도 어린이 수업에 상속되지 않습니다. 귀하의 링크 사이트에서 좀 더 명확하게하기 위해 예제를 약간 변경했습니다. 언급 한 오류 때문에이 예제는 컴파일되지 않습니다.
class mother {
public:
mother()
{ cout << "mother: no parameters\n"; }
explicit mother (int a):m_int(a)
{ cout << "mother: int parameter\n"; }
mother& operator=(mother const& rhs)
{
if(&rhs != this)
{
m_int = rhs.m_int;
}
return *this;
}
mother& operator=(int i)
{
m_int = i;
return *this;
}
private:
int m_int;
};
class son : public mother {
public:
explicit son (int a) : mother (a)
{ cout << "son: int parameter\n\n"; }
};
int main()
{
mother mom(2);
son daniel(0);
mom = 3;
daniel = 4; // compile error
daniel = mom; // also error
}
쓰레기 cplusplus.com 분출물을 합리화하려는 시도는 어리석은 짓입니다! [좋은 책] (http://jcatki.no-ip.org/fncpp/Resources)을 구입하십시오. –