Lyn's Tip
글 수 75
그냥 코드로 대신한다. 어차피 별거없으니까.
메모리 풀 할때 new 오버로딩 하면 편하다. 그냥 평소처럼 쓰면 되니까. 언제든지 되돌릴수 있고
class Test
{
public:
int a;
int b;
void* operator new(size_t size)
{
printf("한개할당중\n");
Test* temp = (Test*)malloc(size);
return temp;
}
void* operator new[](size_t size)
{
printf("%d 개할당중\n", size / sizeof(Test));
Test* temp = (Test*)malloc(size);
return temp;
}
Test()
{
a = b = 123;
}
};
int _tmain(int argc, _TCHAR* argv[])
{
Test* t1, *t2;
t1 = new Test;
t2 = new Test[10];
return 0;
}
