Wouldn’t it be nice to be able to read and write rational numbers directly, for example, std::cout << rational{355, 113}? In fact, C++ has everything you need, although the job is a little trickier than perhaps it should be. This Exploration introduces some of the pieces you need to accomplish this.
Input Operator
The I/O operators are just like any other operators in C++, and you can overload them the way you overload any other operator. The input operator, also known as an extractor (because it extracts data from a stream), takes std::istream& as its first parameter. It must be a non-const