Yes. If you print an enum, you will just see it's corresponding numeric value. If you want to print something of value for an enum, you must check what the enum is and print something manually. You could, of course, overload the insertion operator for your enum type so it will always print a meaningful value on an output stream. For example:
Code:
#include <iostream>
using namespace std;
enum value_type { VT_NONE, VT_ON, VT_OFF };
ostream& operator<<(ostream &out, const value_type &vt) {
switch (vt) {
case VT_NONE: return out << "none";
case VT_ON: return out << "on";
case VT_OFF: return out << "off";
}
return out;
}
int main() {
value_type vt = VT_ON;
cout << vt << endl;
return 0;
}
Originally Posted by
output
on