Skip to content

Latest commit

 

History

History
15 lines (8 loc) · 787 Bytes

7.46.md

File metadata and controls

15 lines (8 loc) · 787 Bytes

(a) A class must provide at least one constructor.

True. If the programmer doesn't provide any constructor, the compiler will synthesise one default constructor.

(b) A default constructor is a constructor with an empty parameter list.

Untrue. A constructor of which all parameters have default values also defines a default constructor.

(c) If there are no meaningful default values for a class, the class should not provide a default constructor.

True. <!--- Need more consideration. --->

(d) If a class does not define a default constructor, the compiler generates one that initializes each data member to the default value of its associated type.

Untrue. Only if a class does not define any constructors, will the compiler generate synthesised default constructor.