मराठी

Features of a Constructor

Topics

Advertisements
CISCE: Class 10

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 

 } 

Advertisements
Share
Notifications



      Forgot password?
Use app×