c/c++ new delete 思考

/* #include <iostream> using namespace std; */ #include <stdio.h> #include <stdlib.h> #include <new> void* operator new(size_t size) { printf("malloc %u/n", size); return malloc(size); } void operator delete(void *memblock) { printf("free/n"); free(memblock); } class abc { public: abc() { printf("abc/n"); throw int(); } ~abc(){printf("~abc/n");} }; int main() { abc* p = NULL; try { p = new abc; } catch(int& i) { printf("%d/n", i); } delete(p); return 0; }  

你可能感兴趣的:(delete,Class)