LogiQuest
Back to Exception Handling
2

What will be the output of the program?

#include <iostream>
#include <string>
#include <exception>
using namespace std;

int main() {
    try {
        throw string("oops");
    } catch (const exception &e) {
        cout << "std" << endl;
    } catch (const string &s) {
        cout << s << endl;
    }
    return 0;
}
Medium

Discussion (0)

  • No discussion yet. Ask a doubt or share a shortcut.

Log in to join the discussion.