Share
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Sorry, you do not have a permission to add a question, You must login to ask question.
gourav
A constructor is a special kind of function that has:
A constructor is automatically executed when an object of a class is created.
Also, Constructor mainly is of two types:
gourav
A constructor is a special kind of class member function that is
executed when an object of that class is represented as constructors
are typically used to initialize member variables of the class to
appropriate default values,or to allow the user to easily initialize
member variables to whatever values are desired.
unlike normal functions,constructors have specific rules for how
they must be named:
1. constructors should always have the same name as the class.
2.constructors have no return type.
A constructor that takes no parameters is called a default
constructor but if you need,a constructor can have parameters.
This helps you to assign initial value to an object at the time of
its creation.