64,649
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#define NEWINT(a) new int[a]
#define DELETE(a) { delete a; a = NULL; }
int main(int argc, char* argv[])
{
int *a , *b;
a =NEWINT(50);
printf("0x%08X\n",a);
DELETE(a);
a = NEWINT(50);
printf("0x%08X\n",a);
DELETE(a);
a = NEWINT(20);
printf("0x%08X\n",a);
DELETE(a);
a = NEWINT(100);
printf("0x%08X\n",a);
DELETE(a);
a = NEWINT(50);
b = NEWINT(50);
DELETE(a);
a = NEWINT(100);
printf("0x%08X\n",a);
DELETE(a);
DELETE(b);
return 0;
}
内存池,对象池都是一种优化手段,你觉得合适就用,如果你连怎么实现的也不知道,没必要来发这个帖子.