The reason you are getting the error is because || has a higher precedence than =. The following expression:
Code:
userInput = 'B' || userInput = 'D' || userInput = 'Q'
is equivalent to:
Code:
userInput = ('B' || userInput) = ('D' || userInput) = 'Q'
And because the = operator has right-to-left associativity, the compiler complains that:
which results in a boolean value, is an invalid lvalue. (It's like trying to say true = 'X'.)
Of course, what you probably meant was to use the == operator, which produces the much more reasonable expression:
Code:
userInput == 'B' || userInput == 'D' || userInput == 'Q'
The following lines should also be producing errors though:
Code:
char 'B';
char 'C';
char 'Q';
char 'X';
Not sure what you had in mind when you wrote that.