我正在玩的时候,正在查看io状态的Microsoft代码,发现了类似这样的内容:
enum _Iostate
{ // constants for stream states
_Statmask = 0x17};//What is this mask for???
static const _Iostate goodbit = (_Iostate)0x0;
static const _Iostate eofbit = (_Iostate)0x1;
static const _Iostate failbit = (_Iostate)0x2;
static const _Iostate badbit = (_Iostate)0x4;
static const _Iostate _Hardfail = (_Iostate)0x10;
我只是想知道为什么要使用此掩码,因为没有该掩码的代码就可以工作,而使用此掩码时,值却保持不变。
谢谢。
最佳答案
确保_Iostate
枚举具有正确的大小,以容纳以后定义的所有位常量及其组合。
关于c++ - 枚举中的掩码[C++],我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/1852108/