adplus-dvertising
frame-decoration

Question

What is the output of this program?
    #include <iostream>
    using namespace std;
    class Base
    {
        public:
        Base ( )
        {
            cout << "1" << endl;
        }
        ~Base ( )
        {
            cout << "2" << endl;
        }
    };
    class Derived : public Base
    {
        public:
        Derived  ( )
        {
            cout << "3" << endl;
        }
        ~Derived ( )
        {
            cout << "4" << endl;
        }    
    }; 
    int main( )
    {
        Derived x;
    }

a.

1234

b.

4321

c.

1423

d.

1342

Answer: (d).1342

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?