🎙 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 9 of 10

How do you make a class impossible to copy?

How do you make a class impossible to copy?

  1. A.Make all members private
  2. B.Write an empty copy constructor
  3. C.Declare the copy constructor and copy assignment as = delete
  4. D.Add a virtual destructor
Answer & explanation

Correct answer: Declare the copy constructor and copy assignment as = delete

Deleted functions turn any copy attempt into a compile error, as with unique_ptr.

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 →