What will be printed as a result of the following program:
#include <iostream>

void f() {
     throw 10;
}

int main() {
    try {
        f();
    } catch (...) {
        std::cout << "all ";
    } catch (double) {
        std::cout << "double ";
    } catch (int) {
        std::cout << "int ";
    }
    return 0;
} 
Explanation
The catch(...) block {/*....*/} must be the last in the series of exception traps. Standard 15.3.6 Otherwise, this block will always be controlled if an exception occurs, regardless of whether there is a more suitable processing block for the excited exception or not (in this case, if there was no compilation error, catch(int) would be skipped).

Follow CodeGalaxy

Mobile Beta

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