adplus-dvertising
frame-decoration

Question

What is the output of this program?
    #include <iostream>
    #include <typeinfo>
    #include <exception>
    using namespace std;
    class base 
    { 
        virtual void f(){} 
    };
    class derived : public base {};
    int main () 
    {
        try 
        {
            base* a = new base;
            base* b = new derived;
            cout << typeid(*a).name() << '\t';
            cout << typeid(*b).name();
        } 
        catch (exception& e) 
        { 
            cout << "Exception: " << e.what() << endl; 
        }
        return 0;
    }

a.

base*

b.

derived*

c.

4base and 7derived

d.

none of the mentioned

Answer: (c).4base and 7derived

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this program?