A class can include a special function called it's constructor, which is automatically called whenever a new object of this class is created. The constructor function is declared just like a regular member function, but with a name of the class and without any return type, not even void. It prepares the new object for use, often accepting arguments that the constructor uses to set required member variables.
Click here for Constructor in C++
Comments
Post a Comment