Advertisement
TwITe

Untitled

Dec 29th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <iostream>
  2. #include <memory>
  3. using namespace std;
  4.  
  5. class A {
  6. public:
  7.     int* data;
  8.  
  9.     A(int* d) : data(d) {
  10.         throw runtime_error("err");
  11.     }
  12.  
  13.     ~A() {
  14.         cout << "A" << endl;
  15.     }
  16. };
  17.  
  18. class B {
  19. public:
  20.     int* data2;
  21.     A* a;
  22.  
  23.     int* arg;
  24.     B(int* s) try : data2(s), a(new A(arg = new int(2))) {
  25.     }
  26.     catch (exception e) {
  27.         delete arg;
  28.     }
  29.  
  30.     ~B() {
  31.         cout << "B" << endl;
  32.     }
  33. };
  34.  
  35. int main() {
  36.     try {
  37.         int arr[] = {1, 2, 3};
  38.         B b(arr);
  39.     }
  40.     catch (exception e) {
  41.         cout << "SUCK EXCEPTION";
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement