Constructor and Destructor functions in base and derived classes in C++

There is an order followed by constructor and destructor functions in base and derived classes. A constructor function of base class is called first, then constructor of derived class. After that, destructor of derived class is called first and then destructor of base class.

For Example:

#include <iostream>

using namespace std;

class base {


base() { cout << “Construct base\n”; }

~base() { cout << “Destruct base\n”; }


class der: public base {


der() { cout << “Construct derived\n”; }

~der() { cout << “Destruct derived\n”; }


int main()


der ob;

return 0;



Construct base

Construct derived

Destruct derived

Destruct base

Leave a Reply