#ifndef PERCENT_IO_H #define PERCENT_IO_H #include "percent.h" #includestd::ostream & operator<<(std::ostream & os, Percent const & percent) { os << static_cast (percent) << '%'; return os; } std::istream & operator>>(std::istream & is, Percent & percent) { int p; is >> p; if (is.fail()) { return is; } char c; is >> c; if (c != '%') { is.setstate(std::ios::failbit); } percent = p; return is; } #endif