C++????Щ?£????????
???????????? ???????[ 2014/7/7 10:31:54 ] ????????C++ net
????6 ???????μ?????????
????1???????????????????Σ???????????????????????????????????????????????
????2???????????ж?????????????????????????е??????????Σ?????????????????????????з????
????3???????????ж????????????????ββ????????????Ρ????????????????????????????????????????ж?????????
????4?????????????????????е????????????????????????????壬??????塣
????7 ?????????????
??????????????????????????????Щ??????????????????????????????????????????????
????7.1 ??????????
????????????????????????У??????????????????????????????????
??????????C++11?У?????????????????????????????????????????????????????????????????????
???????????л??????????????????????????????using???????????????????????????????????????????????????????????????????
????class Bulk_qute : public Disc_quote{
????public:
????using Disc_quote::Disc_quote; // ???Disc_quote???????
????double net_price(size_t) const;
????};
???????????????????????????????????????????б????ù?????????????С?
????7.2 ??????????????????
?????????????????????????????????????????????Щ????????????????????????????????????protected?????????????????????á?
????7.3????????????
????1????????????????????
???????????裺1???????????????????????????????????2???ó?????????????????????????????г????
????2??????????????
?????????????????????г???????????????????????????????????????????ж??塣
????3??????????????????
??????????????????????б????????????????????????????????????????????б??????????????Щ?????
????Bulk_item(const string& book?? double sales_price?? size_t qty = 0?? double disc_rate = 0) : Item_base(book?? sales_price)?? min_qty(qty)?? discount(dis_rate){}
????4???????????????
???????ж????е?????£???????????????????????????????
????5???????????
???????????????????????????????????????public??protected???????????г???????????????????????????????????????????
????7.3 ??????????
????7.3.1 ???????????????????
???????????????????????????????????????????????????彫????????????塣?????????????????????????????????????????????????????????????????????????
????????????????????У?????????????????????????????????β?????????????????????????????????????????δ???
???????????????????????????????????????????????????????????壬??????????????????????????
????7.3.2 ?????????????
??????????????????????????????????????????????
Derived& Derived::operator=(const Derived &rhs)
{
if (this != &rhs)
{
Base::operator=(rhs);
// then do
}
return *this;
}
|
????????????????????????????????????????????????????????????????????????????????????????????????????????????
????7.3.4 ??????????
????Item_base *itemP = new Item_base;
????delete itemP;
????itemP = new Bulk_item;
????delete itemP;
????????????У???delete????????????????????????????????????itemP?????????????????????????????????????????н?θ???????????ò??????????????
??????????????????????麯????virtual ~Item_base(){}
????7.3.5 ??????????????????е????麯??
???????е????????????????????????????????汾??
??????
![](/images/ad-banner/ad-banner.png)
???·???
??????????????????
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