diff --git a/07.AdapterPattern/2.Code/main.cpp b/07.AdapterPattern/2.Code/main.cpp index 6a669b3..a7075e3 100644 --- a/07.AdapterPattern/2.Code/main.cpp +++ b/07.AdapterPattern/2.Code/main.cpp @@ -7,5 +7,6 @@ int main() controller->pathPlanning(); system("pause"); + delete controller; return 0; } \ No newline at end of file diff --git a/08.BridgePattern/2.Code/main.cpp b/08.BridgePattern/2.Code/main.cpp index ff36da4..ac91648 100644 --- a/08.BridgePattern/2.Code/main.cpp +++ b/08.BridgePattern/2.Code/main.cpp @@ -14,10 +14,14 @@ int main() printf("++++++++++++++++++++++++++++++++++\n"); //Jungle想在这个手机上玩游戏B + delete game; game = new GameB(); phone->setupGame(game); phone->play(); + delete phone; + delete game; + system("pause"); return 0; } \ No newline at end of file diff --git a/09.CompositePattern/2.Code/main.cpp b/09.CompositePattern/2.Code/main.cpp index 98c635f..d528555 100644 --- a/09.CompositePattern/2.Code/main.cpp +++ b/09.CompositePattern/2.Code/main.cpp @@ -21,7 +21,6 @@ int main() office5 = new AdminOffice("行政办公室"); office6 = new DeanOffice("教务办公室"); - office7 = new AdminOffice("行政办公室"); office8 = new DeanOffice("教务办公室"); @@ -40,9 +39,22 @@ int main() head->add(office2); head->add(sichuanBranch); - head->operation(); system("pause"); + + delete head; + delete sichuanBranch; + delete cdBranch; + delete myBranch; + delete office1; + delete office2; + delete office3; + delete office4; + delete office5; + delete office6; + delete office7; + delete office8; + return 0; } \ No newline at end of file diff --git a/10.DecoratorPattern/2.Code/main.cpp b/10.DecoratorPattern/2.Code/main.cpp index b19f0f3..509aea0 100644 --- a/10.DecoratorPattern/2.Code/main.cpp +++ b/10.DecoratorPattern/2.Code/main.cpp @@ -3,14 +3,14 @@ int main() { - printf("\nJungle的第一个手机:\n"); + printf("\nJungle's first phone\n"); Component *c; Component *com_Shell; c = new Phone(); com_Shell = new DecoratorShell(c); com_Shell->operation(); - printf("\nJungle的第二个手机:\n"); + printf("\nJungle's second phone'\n"); Component *c2; Component *com_Shell2; c2 = new Phone(); @@ -19,7 +19,7 @@ int main() com_Sticker = new DecoratorSticker(com_Shell2); com_Sticker->operation(); - printf("\nJungle的第三个手机:\n"); + printf("\nJungle's third phone'\n"); Component *c3; Component *com_Shell3; c3 = new Phone(); @@ -32,6 +32,15 @@ int main() printf("\n\n"); + delete c; + delete com_Shell; + delete c2; + delete com_Shell2; + delete com_Sticker; + delete c3; + delete com_Sticker2; + delete com_Rope; + system("pause"); return 0; } \ No newline at end of file diff --git a/11.FacadePattern/2.Code/main.cpp b/11.FacadePattern/2.Code/main.cpp index 256b819..2191797 100644 --- a/11.FacadePattern/2.Code/main.cpp +++ b/11.FacadePattern/2.Code/main.cpp @@ -7,7 +7,7 @@ int main() facade->powerOn(); printf("\n\n"); - + delete facade; system("pause"); return 0; } \ No newline at end of file diff --git a/12.FlyweightPattern/2.Code/main.cpp b/12.FlyweightPattern/2.Code/main.cpp index 51d55a2..04a76da 100644 --- a/12.FlyweightPattern/2.Code/main.cpp +++ b/12.FlyweightPattern/2.Code/main.cpp @@ -30,6 +30,12 @@ int main() printf("\n\n"); + delete factory; + delete device1; + delete device2; + delete device3; + delete device4; + system("pause"); return 0; } \ No newline at end of file diff --git a/13.ProxyPattern/2.Code/main.cpp b/13.ProxyPattern/2.Code/main.cpp index 132e87e..b563585 100644 --- a/13.ProxyPattern/2.Code/main.cpp +++ b/13.ProxyPattern/2.Code/main.cpp @@ -9,6 +9,8 @@ int main() printf("\n\n"); + delete subject; + system("pause"); return 0; } \ No newline at end of file diff --git a/14.ChainOfResponsibility/2.Code/main.cpp b/14.ChainOfResponsibility/2.Code/main.cpp index fc5bf9f..a132cdc 100644 --- a/14.ChainOfResponsibility/2.Code/main.cpp +++ b/14.ChainOfResponsibility/2.Code/main.cpp @@ -28,6 +28,16 @@ int main() zuzhang->handleRequest(bill4); printf("\n\n"); + + delete zuzhang; + delete bingge; + delete chunzong; + delete laoban; + delete bill1; + delete bill2; + delete bill3; + delete bill4; + system("pause"); return 0; } \ No newline at end of file