fork download
  1. # include <iostream>
  2. # include <cstdlib>
  3. using namespace std;
  4.  
  5. class Test {};
  6. void * operator new (size_t size) throw (std::bad_alloc){
  7. cout<<"Calling New:"<<endl;
  8. return new (malloc(size)) Test() ;
  9. }
  10.  
  11. void operator delete (void *ptr) throw () {
  12. cout<<"Calling Delete:"<<endl;
  13. free (ptr) ;
  14. }
  15.  
  16. int main ()
  17. {
  18. cout<<"Hello"<<endl;
  19. Test *ptr = new Test () ;
  20. delete ptr ;
  21. return 0;
  22. }
Success #stdin #stdout 0s 2984KB
stdin
Standard input is empty
stdout
Hello
Calling New:
Calling Delete: