What will the following program print?
#include <iostream>

using namespace std;

struct A {
    A() {
        cout << 1;
        throw 0; 
    }
};

struct B: A {
    B() try: A() {
        cout << 2;
    }
    catch(...) {
        cout << 3;
    }
};

int main() try {
    B b;
    cout << 4;
}
catch (...) {
    cout << 5;
}

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes