C++ constructor is used to initializing the member variables of an instance of a class that is the object of a class. A constructor is a particular type of member function that initializes an object automatically when it is created. The compiler identifies a given member function is a constructor by its name and the return type.
The constructor has the same name as that of a class, and it does not have any return type. Also, the constructor is always public.
A constructor is the member function of a class. But they do differ from actual function in the following ways:
#c++ #c++ constructor