Order of Execution of Constructor and Destructor when Inherited
This video tutorial made by the learning lad explains the order of execution of constructors and destructors when a derived class inherits from a base class.
You will learn in which order constructors and destructors are called when inheritance is used in c++ in detail with example.
source code for this tutorial
#include <iostream> using namespace std; class Person{ public: Person(){ cout << "constructor of the Person class called"<<endl; } ~Person(){ cout << "destructor of the Person class called"<<endl; } }; class Student : public Person{ public: Student(){ cout << "constructor of the Student class called"<<endl; } ~ Student(){ cout << "destructor of the Student class called"<<endl; } }; int main() { Student anil; return 0; }