Home » C++ Programming » Templates » Question
  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    class BaseClass
    {
    public:
    BaseClass( )
    {
    cout << "I ";
    }
    ~BaseClass ( )
    {
    cout << " Mania";
    }
    };
    class DerivedClass : public BaseClass
    {
    public:
    DerivedClass ( )
    {
    cout << "Love ";
    }
    ~DerivedClass ( )
    {
    cout << "Interview";
    }
    };
    int main( )
    {
    DerivedClass x;
    }
    1. I
    2. Love
    3. Interview
    4. Mania
    5. I Love Interview Mania
Correct Option: E

In this program, We are printing the order of execution of constructor and destructor in the class.



Your comments will be displayed only after manual approval.