Okay i have to check a string for some things, heres the rules
------
If the first letter is a consonant, move it to the end of the string and add “ay” to the end.
If the first letter is a vowel, add “way” to the end.
------
So I have this function, but it wont go to the else statement, it will only assume that the first char is a vowel.
(fn[0]=='a') or 'e' //how it evaluates because of precedence rules
fn[0] == ('a' or 'e') //this would be wrong too
('a' or 'e') //evaluates to true
fn[0] == 'a' and 'e' //¿does this make sense to you?
fn[fn.length() + 1] //accessing out of bounds is an error
Because if (x == 1 || x == 2) is not the same as if (x == 1 || 2). You've hard coded a value in there what will always be true, therefore negating the condition
while(true) is a single condition, so it's ok to use because there is no possible confusion.
if (x == 1 || 2) will always result in true because the if statement is incorrectly written to be logically correct. Regardless of x's value it will always equate to true. In this scenario it's not as bad as it could be because the condition is before the hard-coded true value. Looking at the OPs code he had coded his IF statement incorrectly for the logic he wanted to achieve.
while(true) is a single condition, so it's ok to use because there is no possible confusion.
if (x == 1 || 2) will always result in true because the if statement is incorrectly written to be logically correct.
if ( x==1 || 2 ) is also a single condition. Ask any optimizer. The compiler is not supposed to verify logic.
What if the condition isn't connected with an or? What if it's connected with an &&? What if one of the conditions is only included for it's side effect? What if one of the conditions is always true now, but may not be in the future?
Yes, I get how the logical operators work. No, I don't see how a warning (and especially not an error) is called for (unless it's an optional one that is preferably not enabled by default.) Certainly the standard doesn't call for a diagnostic.
This is 2 conditions. If the first condition is true, the second condition is never checked. The sum result of those 2 conditions is 1 condition, but that does not mean that both conditions will be executed. I'd recommend you re-visit how the || and && operators behave in conditional statements.
I also recommend you re-read my original post where I say that the statement is not valid C++. Anyone should be able to realise this was in response to the OP where he had coded the if statement conditions in a way that was not valid for the logic he was trying to portray.