fork download
  1.  
  2. #include <iostream>
  3. using std::cout;
  4. using std::endl;
  5. #include <cstdlib>
  6. using std::malloc;
  7. using std::free;
  8.  
  9. struct Object {
  10. Object() { throw 0; }
  11. void* operator new(size_t s) { cout << "n" << endl; return malloc(s); }
  12. void operator delete(void* ptr) { cout << "d" << endl; free(ptr); }
  13. };
  14.  
  15. int main() {
  16. try {
  17. Object* p = new Object;
  18. } catch(...) { }
  19. }
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:17: warning: unused variable ‘p’
stdout
n
d