Start the enumeration with COLOR=1
Using bitwise operators in switch case
abc abc
351
Reputation points
I have enum,
enum ENUM_MSG_TEXT_CHANGE {COLOR=0,SIZE,UNDERLINE};
void Func(int nChange)
{
switch(nChange)
{
case COLOR:break;
case SIZE:break;
case COLOR|SIZE: break
}
}
case SIZE: and case COLOR|SIZE both gives value 1, so I am getting error error C2196: case value '1' already used. how to differenciate these two cases in switch case?
2 answers
Sort by: Most helpful
-
-
RLWA32 45,691 Reputation points
2020-09-01T11:52:07.52+00:00 Try this
enum ENUM_MSG_TEXT_CHANGE { COLOR = 1, SIZE = 2, UNDERLINE = 4, ITALIC = 8, UGLY = 16, PRETTY = 32, AWESOME = 64 };