Skip to lesson

Must-do problems: Copying Objects

Every problem here asks for a copy that behaves correctly: separate where each side owns its data, shared where there is one real thing. Before you code, decide for each field whether to copy it or share it, then run every test before opening a hint.

What you will learn

What you will learn

  • Copy arrays and 2D arrays so a change to the copy never reaches the original
  • Write copy constructors that deep copy every changeable field
  • Decide field by field what to copy and what to share on purpose
  • Build save points and versions that copy on save and on restore

Sign in to continue this lesson

Create an account to read every lesson, practise with the exercises and keep track of your progress.