Difficulty: Easy
Correct Answer: Copy constructor
Explanation:
Introduction / Context:
Copying semantics determine how values propagate and how resources are duplicated or shared. C++ recognizes a special member function that initializes a new object from an existing one of the same type. Knowing its name and role helps you reason about value semantics and ownership policies (rule of three/five/zero).
Given Data / Assumptions:
Concept / Approach:
The copy constructor has the conventional signature T(const T&). It runs when a new object is constructed from another, including function parameter passing by value and function return by value (subject to elision/moves). A “dynamic constructor” is a colloquial phrase sometimes used for constructors that allocate resources; it is not a standard term. “Create constructor” and “Object constructor” are not C++ terms of art.
Step-by-Step Solution:
Verification / Alternative check:
Delete or make private the copy constructor and observe that copy-initialization fails, proving it is the mechanism used by the compiler for such constructions. Implementing a move constructor changes behavior for rvalues but not lvalue copies.
Why Other Options Are Wrong:
Create/Object constructor: non-standard labels.
Dynamic constructor: vague; not the standardized name for copying.
Common Pitfalls:
Final Answer:
Copy constructor
Discussion & Comments