Constructor in C++

C++ provides a special member function called the constructor which enables an object to initialize itself when it is created. What is Constructor ? “A constructor is a special member function whose task is to initialize the objects of its class.” It is special because its name is the same name as the class name. The constructor is invoked whenever an object of its associated class is created. It is called constructor because it constructs the values of data members of the class. Syntax: A constructor is declared and defined…

Read More