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

What will be the output of the following C++ code?
Code:
    #include <iostream>
    using namespace std;
    void Funct();
    int main()
    {
        try 
        {
            Funct();
        }
        catch(double) 
        {
            cerr << "caught a double type..." << endl;
        }
        return 0;
    }
    void Funct()
    {
        throw 3;
    }
A. caught a double type
B. compile time error
C. abnormal program termination
D. runtime error
 
Answer: c
Explanation: As we are throwing integer to double it will raise as abnormal program after termination throw statement.
Output:
Code:
$ g++ excep4.cpp
$ a.out
terminate called after throwing an instance of 'int'
Aborted
 

Tìm kiếm

Back
Top