Technical Discussion :: C++
Home > Technical Interview Q&A > C++ > Discussion
5 / 187
What are properties of the constructor function?
Answer:
• 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 ::
Harendra
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.
• 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.