Difficulty: Easy
Correct Answer: default constructor
Explanation:
Introduction / Context:
Default construction is ubiquitous in C++ because containers, arrays, and many APIs require the ability to create objects without supplying arguments. Understanding precisely what qualifies as a “default constructor” clarifies why certain code compiles—or fails—when zero-argument construction is attempted.
Given Data / Assumptions:
Concept / Approach:
A default constructor is any constructor that can be invoked with no arguments. This includes a function with an empty parameter list and also a constructor where every parameter has a default value, allowing calls with zero arguments. A copy constructor is distinct; it takes a reference to another object of the same type and initializes from it. Therefore, “default constructor” is the correct term for the described case, not “copy constructor” and not “both.”
Step-by-Step Solution:
Verification / Alternative check:
Declare T(int x = 1); and invoke T(). This compiles, demonstrating that defaulted parameters still yield a default constructor. Removing defaults and leaving only T(int) breaks zero-argument construction, illustrating the definition’s boundary.
Why Other Options Are Wrong:
Copy constructor: not callable with zero arguments.
Both A and B: mixes distinct concepts.
None of these: incorrect since a well-known term exists.
Common Pitfalls:
Final Answer:
default constructor
Discussion & Comments