Advertisement
Guest User

Untitled

a guest
Aug 20th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class A {
  5. int i;
  6. public:
  7. static void* operator new(std::size_t size) throw(std::bad_alloc) {
  8. return malloc(size);
  9. }
  10. static void operator delete(void* p) throw() {
  11. cout << "delete" << endl;
  12. free(p);
  13. }
  14. A() throw(std::exception) {
  15. throw exception();
  16. }
  17. };
  18.  
  19. void operator delete(void* p) throw() {
  20. cout << "delete" << endl;
  21. free(p);
  22. }
  23.  
  24. int main() {
  25. A* a = new A;
  26. }
  27.  
  28. terminate called after throwing an instance of 'std::exception'
  29. what(): std::exception
  30. [1] 28476 abort ./test_clion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement