C++ Constructor

C++ Constructor

Just at the time of the creation of an object a special method that is invoked automatically is known as the constructor in C++. The general use of the constructor lies in initializing the new object's data members and it generally has the same name as the class or the structure.

There are two types of known constructor in C++.

Default constructor

Parameterized constructor

1. C++ Default Constructor

The constructor that is generally invoked at the creation of an object and contains nil arguments is known as the default constructor in C++.