Here we explore:
- how
std::optionaloffers an alternative to errors codes and exceptions. - how the insertion of a
std::optionalaffects following functions.
- slides about
std::optional
In the file optional.cpp, modify the function mysqrt below so that it returns an std::optional<double> rather than a double, and the program prints nothing rather than nan for the call with -10. It will also require to modify square.