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

Lò Ngọc

New member
What will be the output of the following C++ code?
Code:
    #include <iostream>
    using namespace std;
    void test(int x)
    {
        try
        {
            if (x > 0)
                throw x;
            else
                throw 'x';
        }
        catch(int x)
        {
            cout<<"integer:"<<x;
        }
        catch(char x)
        {
            cout << "character:" << x;
        }
    }
    int main()
    {
        test(10);
        test(0);
    }
A. integer:10character:x
B. integer:10
C. character:x
D. character:10
 

Tìm kiếm

Back
Top