C++ constructors: which of the following is NOT a constructor type?

Difficulty: Easy

Correct Answer: Friend constructor

Explanation:


Introduction / Context:
Constructors initialize objects and establish class invariants. C++ recognizes several common constructor categories by usage rather than special keywords. This question checks whether you can distinguish real constructor types from invalid notions in standard C++ terminology.


Given Data / Assumptions:

  • We consider standard C++ (not vendor extensions).
  • Constructor names match the class name and have no return type.
  • Friendship grants access; it is not a kind of constructor.


Concept / Approach:

Recognized categories include: default constructor (no parameters), parameterized constructor (with parameters), and copy constructor (takes const Class& under typical form). There is no such thing as a “friend constructor.” The friend keyword grants another function or class access to private/protected members; it does not turn a constructor into a different “type.” Constructors themselves can be friends of another class, but that does not create a new constructor category.


Step-by-Step Solution:

1) List standard categories: default, parameterized, copy (and move in modern C++). 2) Evaluate “friend constructor”: not a standard category—friendship is an access relationship. 3) Conclude that “Friend constructor” is not a constructor type. 4) Therefore, it is the correct choice for “not a type.”


Verification / Alternative check:

Reviewing language references shows friend applies to functions/classes for access control. A constructor may be declared friend of another class, but its own classification remains default/parameterized/copy/move.


Why Other Options Are Wrong:

Copy constructor: initializes from another object of the same type.

Default constructor: callable with no arguments.

Parameterized constructor: accepts arguments to customize initialization.


Common Pitfalls:

  • Confusing friend with constructor categories.
  • Forgetting move constructors (C++11+)—not listed here but standard.


Final Answer:

Friend constructor

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion