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" << endl;
- //delete data;
- }
- };
- class B {
- public:
- int* data2;
- A* a;
- B(int* s) try : data2(nullptr), a(nullptr) {
- data2 = s;
- a = new A(2);
- }
- catch (exception e) {
- //delete data2;
- delete a;
- }
- };
- int main() {
- try {
- int arr[] = {1, 2, 3};
- B b(arr);
- }
- catch (exception e) {
- cout << "EXCEPTION SUCK";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement