In this example we use stod (string to double: pronounce S-to-D) to convert the input to a double.
As you can see, check for an catching errors makes the program much longer.