🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Copy Constructor and Deep Copy: all 10 questions

Quiz: Copy Constructor and Deep Copy · Question 5 of 10

Why must the copy constructor take its parameter by reference?

Why must the copy constructor take its parameter by reference?

  1. A.References are faster to type
  2. B.Passing by value would itself need a copy, calling the copy constructor endlessly
  3. C.Because constructors cannot take values
  4. D.So the original can be changed
Answer & explanation

Correct answer: Passing by value would itself need a copy, calling the copy constructor endlessly

The compiler rejects T(T other) for this reason; use const T &.

Can you get the rest right without peeking?

Take the timed Quiz: Copy Constructor and Deep Copy quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →