4 / 187
What are characteristics of the constructor function?
The constructor functions have some characteristics:
• They should be declared in the public section.
• They got invoked automatically when the objects are created.
• They do not have return types, not even void and therefore, they cannot return values.
• They cannot be inherited, through a derived class can call the base class constructor.
• Like other c++ functions, they can have default arguments.
• Constructors cannot be virtual.
• We cannot refer to their addresses.
• An object with a constructor cannot be used as a member of a union.
• They make implicit calls to the operators new and delete when memory allocation is required.
When a constructor is declared for a class, initialization of the class objects becomes mandatory.
Asked In ::
Parash Singh
23 Feb, 2019 5:07 AM
• They should be declared in the public section.
• They got invoked automatically when the objects are created.
• They do not have return types, not even void and therefore, they cannot return values.
• They cannot be inherited, through a derived class can call the base class constructor.
• Like other c++ functions, they can have default arguments.
• Constructors cannot be virtual.
• We cannot refer to their addresses.
• An object with a constructor cannot be used as a member of a union.
• They make implicit calls to the operators new and delete when memory allocation is required.
When a constructor is declared for a class, initialization of the class objects becomes mandatory.