Refine memory leak 1

master
FengJungle 2020-11-29 10:02:40 +08:00
parent 8f767aa8b8
commit c77d3d9a0c
4 changed files with 24 additions and 7 deletions

View File

@ -6,11 +6,14 @@ int main()
GameAccount *jungle = new GameAccount("Jungle");
for (int i = 0; i < 5; i++){
printf("第%d局\n", i + 1);
printf("%d \n", i + 1);
jungle->playCard();
}
printf("\n\n");
system("pause");
delete jungle;
return 0;
}

View File

@ -7,22 +7,25 @@ int main()
Context* ctx = new Context();
int arr[] = { 10, 23, -1, 0, 300, 87, 28, 77, -32, 2 };
ctx->setInput(arr, sizeof(arr)/sizeof(int));
printf("输入:");
printf("input:");
ctx->print();
// 冒泡排序
// BubbleSort
ctx->setSortStrategy(new BubbleSort());
ctx->sort();
// 选择排序
// SelectionSort
ctx->setSortStrategy(new SelectionSort());
ctx->sort();
// 插入排序
// InsertSort
ctx->setSortStrategy(new InsertSort());
ctx->sort();
printf("\n\n");
system("pause");
delete ctx;
return 0;
}

View File

@ -5,15 +5,18 @@ int main()
{
FingerprintModule *fp = new FingerprintModuleA();
fp->algorithm();
delete fp;
fp = new FingerprintModuleB();
fp->algorithm();
delete fp;
fp = new FingerprintModuleC();
fp->algorithm();
delete fp;
printf("\n\n");
system("pause");
return 0;
}

View File

@ -29,8 +29,16 @@ int main()
printf("\n\n");
shoppingCart->accept(cashier);
printf("\n\n");
system("pause");
delete apple1;
delete apple2;
delete book1;
delete book2;
delete cashier;
delete jungle;
delete shoppingCart;
return 0;
}