Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Order of Constructor/ Destructor Call in C++
In this tutorial, we will be discussing a program to understand the order of constructor/ destructor in C++.
Order of constructor/destructor refers to the pattern in which the constructors of various classes are called during inheritance of classes.
Example
#include <iostream>
using namespace std;
//parent class
class Parent{
public:
Parent(){
cout << "Inside base class" << endl;
}
};
//child class
class Child : public Parent{
public:
Child(){
cout << "Inside sub class" << endl;
}
};
int main() {
Child obj;
return 0;
}
Output
Inside base class Inside sub class
Advertisements