class Base { public: Base() { cout << "Base Constructor" << endl; } ~Base() { cout << "Base Destructor" << endl; } }; class Derived : public Base {…

class Base {
public:
    Base() {
        cout << "Base Constructor" << endl;
    }

    ~Base() {
        cout << "Base Destructor" << endl;
    }
};

class Derived : public Base {
public:
    Derived() {
        cout << "Derived Constructor" << endl;
    }

    ~Derived() {
        cout << "Derived Destructor" << endl;
    }
};

int main() {
    Derived obj;
    return 0;
}

Write the exact output of the program and briefly explain the order in which the constructors and destructors are executed.

From the NPCBL Engineer (Software / Programming) June 2026 – Written (BUET) exam, question 3 of 3.

Answers (1)

Base Constructor
Derived Constructor
Derived Destructor
Base Destructor

— rhs

More from this paper