- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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
- Related Articles
- Difference Between Constructor and Destructor
- attribute((constructor)) and attribute((destructor)) syntaxes in C in tutorials point ?
- How to call a static constructor or when static constructor is called in C#?
- How to call the constructor of a superclass from a constructor in java?
- Virtual Destructor in C++
- Private Destructor in C++
- How to call Private Constructor in Java
- Pure virtual destructor in C++
- How to explicitly call base class constructor from child class in C#?
- How to call the constructor of a parent class in JavaScript?
- How to call one constructor from another in Java?
- How can we call one constructor from another in the same class in C#?
- How to call parent constructor in child class in PHP?
- Java Program to Call One Constructor from another
- Can we call a constructor directly from a method in java?

Advertisements