Advertisement
TwITe

Untitled

Dec 28th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Derived {
  5. public:
  6.     Derived() {
  7.         cout << "Derived constructor" << endl;
  8.     }
  9.  
  10.     ~Derived() {
  11.         cout << "Derived destructor" << endl;
  12.     }
  13. };
  14.  
  15. class Base {
  16. private:
  17.     int *a;
  18. public:
  19.     Base() {
  20.         Derived b;
  21.  
  22.         a = new int[100];
  23.  
  24.         throw runtime_error("error");
  25.     }
  26.  
  27.     ~Base() {
  28.         // delete[] a;
  29.     }
  30. };
  31.  
  32. int main() {
  33.     try {
  34.         Base base;
  35.     }
  36.     catch (exception e) {
  37.  
  38.     }
  39.  
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement