English

Features of a Constructor

Advertisements

Topics

Features of a constructor:

A constructor is defined with the same name as the class, used solely for initializing data members and is called automatically when an object is created, needing no explicit call or return type. It is always public and can be overloaded by defining multiple constructors with different parameters. 

     Syntax to define a constructor 

Note: class<class name> 

{ 

//Content of class 

} 

<class name>() 

{ 

//content of constructor 

 } 

If you would like to contribute notes or other learning material, please submit them using the button below.
Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×