Advertisement
TwITe

Untitled

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