How to do it...

In this section, we will write a little game that prompts the user to enter a specific word. The time that the user needs to type this word into the keyboard is measured and displayed in multiple time units:

  1. At first, we need to include all the necessary headers. For reasons of comfort, we declare that we use the std namespace by default:
      #include <iostream>      #include <chrono>      #include <ratio>      #include <cmath>      #include <iomanip>      #include <optional>            using namespace std;
  1. The chrono::duration as a type for time durations usually refers to multiples or fractions of seconds. All the STL time duration units refer to integer typed duration specializations. In this recipe, we are going to specialize on double. In the recipe after ...

Get Expert C++ Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.