Introduction
After learning a bit about classes, objects, and access modifiers, we can move on to another important concept of Constructors and Destructors. This part will cover Constructors. We’ll explore what are constructors, why we need them, types of constructors, and their semantics in C++ as usual.
So without wasting any time, let’s get started.
What is a constructor
A constructor is a method just like another method in a class, but it has a special name for a reason. The name itself speaks, Constructor, which will get called just after the object gets created. A constructor is just a method but it should only have the name same as of the class, that’s the thing that distinguishes it from other methods.