← 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?
- A.Make all members private
- B.Write an empty copy constructor
- C.Declare the copy constructor and copy assignment as = delete
- 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 →