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