C++?е????????????????????
???????????? ???????[ 2012/10/17 10:16:06 ] ????????
????3.2 ?????????????????е??麯??????
???????????麯???????????????????????????б???????????????????????????“??”???????????????????????????????????“???”?????磺
class A
{
public:
A() { foo();} // ????????????ζ???A::foo()???????
~A() { foo();} // ???
virtual void foo();
};
class B: public A
{
public:
virtual void foo();
};
void bar()
{
A * a = new B;
delete a;
}
????????????delete a?????????B::foo()???????????????????????new B?????A????????????????????A????????У??????????A::foo()??????B::foo()??
????3.3 ?????е??麯??
??????е??????????????麯??????????????е??麯??(??????????????)???????е????????????ж???????????????麯???????????????Щ????????????????????????и?????麯???????????????????麯????????????????????麯??????????????????????麯?????????С?????????????麯????
????3.4 ?????????麯??
??????????????????????????????????????????????????в???????????????????????????????????????????е??麯????????????????????е??麯???????????????????????????????????????????????
???????????[2]??Factory Method???????Creator??factoryMethod()???麯??????????override??????????????????Product??????????Product???????AnOperation()??????á??????AnOperation()???????Product????в????????Product???????ж?????麯??????
??????????????????????????????????????A???????????Σ??????????std::vector[url=]??????????????в?????????????????????????????????е?????в?????????????????????cast??????????????????????????????????????????????????????y????“????????”?????virtual??
????????У?????????????????????????????????????????“????????????????????????????в?????????????????????”????仰?????????????“???????????????麯??????????override??”??
??????
???·???
??????????????????
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