Advertisement
TwITe

Untitled

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