Skip to content
KALANBLON
Show contents

Chapter 3 of 6 · 10 min

Quiz: errors and streams

Exceptions, RAII and streams: let's check that your C++ programs handle errors and data properly. You need 70 % correct answers, and every answer is explained.

Quiz

5 questions · pass mark: 70%

  1. 1.How should you catch a standard exception?

    One answer

  2. 2.A try block is followed by catch (const std::exception&) then catch (const std::invalid_argument&). What does the second one catch?

    One answer

  3. 3.An exception passes through a function that owns a local std::vector and std::ifstream. What happens? (several answers)

    Several answers possible

  4. 4.Complete the function that reads a whole line from a stream.

    Complete the code

    std::string line;
    while (std::_______(input, line)) { ... }
  5. 5.After input >> seats;, why can std::getline(input, name) read an empty line?

    One answer

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