Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <memory>
- using namespace std;
- class A {
- public:
- int* data;
- A(int* d) : data(d) {
- throw runtime_error("err");
- }
- ~A() {
- cout << "A's destructor was called" << endl;
- }
- };
- class B {
- public:
- unique_ptr<int[]> data2;
- A* a;
- B(int* s) : data2(new int[10]), a(new A(s)) {}
- ~B() {
- cout << "B's destructor was called" << endl;
- }
- };
- int main() {
- try {
- int arr[] = {1, 2, 3};
- B c(arr);
- }
- catch (exception e) {
- cout << "EXCEPTION SUCK";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement