int bits = 0;
bool a = true, b = false, c = true; // 101 = 5
bits = bits | a << 2;
bits = bits | b << 1;
bits = bits | c;
cout << bits;
This is the code I am going to use to take a set of three booleans and convert it into an int for a switch statement. I have 8 cases based on the combined state of these 3 booleans. Am I doing this right? Right, not in the sense of the syntax although if there are any problems there please advise. More right in the sense of "Is this the best way to solve this problem?"