What will be the output of the following C++ code? [code] #include <iostream> using namespace std; int main() {

What will be the output of the following C++ code?
Code:
    #include <iostream>
    using namespace std;
    int main()
    {
        try
        {
            throw 1;
        }
        catch (int a)
        {
            cout << "exception number:  " << a << endl;
            return 0;
        }
        cout << "No exception " << endl;
        return 0;
    }
A. No exception
B. exception number
C. exception number: 1
D. exception number: 5
 
Answer: c
Explanation: If we caught a integer value means, there will be an exception, if it is not a integer, there will not be a exception.
Output:
Code:
$ g++ gex1.cpp
$ a.out
exception number: 1
 

Tìm kiếm

Back
Top