13.5 — I/O 运算符重载简介

在上一课中 (),我们展示了这个示例,其中我们使用了一个函数将枚举转换为等效的字符串: #include <iostream> #include <string_view> enum Color { black, red, blue, }; constexpr std::string_view getColorName(Color color) { switch (color) { case black: return “black”; case red: return “red”; case …