Advertisement
TwITe

Untitled

Dec 28th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 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.  
  14. class B {
  15. public:
  16.     int *data2;
  17.     A *a;
  18.  
  19.     B()
  20.     try
  21.             : data2(new int[10]),
  22.               a(new A(new int[2])) {
  23.  
  24.     }
  25.     catch (exception e) {
  26.         delete[] data2;
  27.         delete a;
  28.     }
  29. };
  30.  
  31.  
  32. int main() {
  33.     B b;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement