C++ ??л???????????
???????????? ???????[ 2012/9/20 9:57:15 ] ????????
????????????????????????????????????????????????????????????????????????????????????У???????????????л?????????????????????????????ü??????????????????????????????????????????????????????£???????е???÷?????????????????????????????
class Animal {
public:
Animal &operator=(const Animal &rhs);
...
};
class Animal1: public Animal {
public:
Animal1 &operator=(const Animal1 &rhs);
...
};
class Animal2: public Animal {
public:
Animal2 &operator=(const Animal2 &rhs);
...
};
??????????????????????????????????Animal???????Animal1??Animal2????????????????????????????????????????????????????????????????
Animal1 an1;
Animal1 an2;
Animal *pAn1 = &an1;
Animal *pAn2 = &an2;
...
*pAn1 = *pAn2;
???????????????????????????????????????е???????an2?????an1.?????????????????????????????????????????????и??????????c++???????????????顣????????Ч??????an1??Animal?????an2??Animal??????????an1??Animal1??????????????????3???????????????1?????????е?????????????????????????????????????????????2??????Animal *pAn1 = &an1???????pAn1????????Χ??С??Ч??????????????????????????????????????????????????????Ч?????????????an1??????????????????????an1??x?????????????????an2????????????????????????????????Ч??????????????????÷??????????????c++ ???????????????????????????
??????????????????????????????????????????????????????Ч?????
????????????????л??????????????麯?????????????????????????????麯???????????£?
class Animal {
public:
virtual Animal &operator=(const Animal &rhs);
...
};
class Animal1: public Animal {
public:
virtual Animal1 &operator=(const Animal1 &rhs);
...};class Animal2: public Animal { public: virtual Animal2 &operator=(const Animal2 &rhs);
...};
?????????麯???????????????????????????Ч??????????????????????????????????????????????????Animal1????????????????????????????????μ????
Animal1 an1;
Animal2 an2;//??????Animal2??????????Animal1???
Animal *pAn1 = &an1;
Animal *pAn2 = &an2;
...
*pAn1 = *pAn2;//??Animal2???????Animal1
?????????????????????????????????????????ν?????????ο???More Effective c++???????????34??
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11