나는 이것이 왜 그런지 궁금해합니다. 두 개체가 만들어지는 클래스 안에있는 과부하 정의의 마법의 품질입니까? 나는 그것에 대해 생각하고 있었고, 하나의 함수가 두 객체의 멤버 데이터에 접근 할 수 있다는 것이 약간 이상하다고 느꼈다.할당 연산자 오버로드에 함수가 필요하지 않은 이유는 무엇입니까?
myClass& myClass::operator= (const myClass& a){
// shallow copy
arraySize = a.arraySize; // no get functions needed
// deep copy
theArray = new int[arraySize]; // no get functions needed
for (int i = 0; i < arraySize; i++){
theArray[i] = a.theArray[i];
}
}