1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <new>
4
5 class Test {
6 public:
7 int a, b, c, d;
8 };
9
operator new[](size_t size)10 void *operator new[](size_t size) throw(std::bad_alloc)
11 {
12 void *ret = malloc(size);
13 printf("Here.\n");
14 for (unsigned int i = 0; i < size; i++) ((char *) ret)[i] = 0xFF;
15 return ret;
16 }
17
main(int argc,char * argv[])18 int main(int argc, char *argv[]) {
19 Test *toto;
20 int i;
21 int j = 0;
22
23 toto = new Test[2];
24
25 for (i = 0; i < 2; i++) {
26 if (toto[i].a) {
27 j++;
28 }
29 //printf("%d : %08x %08x %08x %08x\n", i, toto[i].a, toto[i].b, toto[i].c, toto[i].d);
30 }
31 }
32