Skip to content
KALANBLON
Show contents

Chapter 7 of 7 · 10 min

Quiz: objects and memory

Classes, encapsulation, destructors, RAII and unique_ptr: let's check that your objects protect their rules and their memory. You need 70% correct answers.

Quiz

6 questions · pass mark: 70%

  1. 1.Why declare balance_ as private in an Account class?

    One answer

  2. 2.What does the const in double balance() const promise?

    One answer

  3. 3.In what order are the closings displayed?

    One answer

    {
        Logbook a("A");
        Logbook b("B");
    }   // the destructor displays "Closing" + name
  4. 4.Fill in the blank to create an Image object owned by a unique_ptr.

    Complete the code

    auto img = std::____<Image>(Image{800, 600});
  5. 5.Which statements about RAII are true? (several answers)

    Several answers possible

  6. 6.What is img after auto other = std::move(img); with two std::unique_ptrs?

    One answer

Your progress is saved on this device. Create a free account to keep your progress on all your devices.