Constructors
Constructors
What is a Constructor?
• Constructor is a special method that gets invoked
“automatically” at the time of object creation.
• Constructor is used for Initializing the values to the data
members of the class.
• Constructor has the same name as the class name.
• Constructors do not have a return type (not even void) and
they do not return a value.
• A class can have more than one constructor as long as they
have different signature (i.e., different input arguments
syntax).
• Constructors have special syntax:
– must always have the same name as their class
Types of Constructor