fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3. class A
  4. {
  5. public:
  6. A() { }
  7. ~A() noexcept(false) { throw exception(); }
  8. void* operator new ( std::size_t count )
  9. {
  10. cout << "hi" << endl;
  11. return ::operator new(count);
  12. }
  13. void operator delete ( void* ptr)
  14. {
  15. cout << "bye" << endl;
  16. return ::operator delete(ptr);
  17. }
  18. };
  19.  
  20. int main() {
  21. A* a = new A();
  22. try
  23. {
  24. delete a;
  25. }
  26. catch(...)
  27. {
  28. cout << "eek" << endl;
  29. }
  30. return 0;
  31. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
hi
eek