I have an if else statement but it seems to be executing the code under the if and it should execute the code under the else but i cannot see the reason why my code is below.
If you look at the last if statement where it checks to see if those characters are shown if you notice from 0 – 3 D,W,O,P are not in cells 0 – 3 but it still executes the print statement there can someone tell me why?
will be happy for any help
order.push_back("V"); //V
order.push_back("I");//F
order.push_back("F");//I
order.push_back("N");//O
order.push_back("D");//O
order.push_back("W");//O
order.push_back("O");//O
order.push_back("P");//O
order.push_back("Y");//O
order.push_back("C");//O
order.push_back("L");//O
order.push_back("E");//O
order.push_back("R");//O
order.push_back("X");//O
if(order.front() == "V")
{
it = find(order.begin(), order.end(), "I");
++it;
std::string o = *it;
DCS_LOG_DEBUG("NEXT 0 " << o);
DCS_LOG_DEBUG("NEXT " << *it);
int i = find(order.begin(), order.end(), "N") - order.begin();
int pos = i;
DCS_LOG_DEBUG("POS " << pos);
for(int i1 = 0; i1 < pos; i1++)
{
DCS_LOG_DEBUG("IN LINE " << order[i1]);
if(order[i1] == "D" || "W" || "O" || "P")
{
DCS_LOG_DEBUG("It matches one of the above incorrect");
}
else
{
for(pos; pos < order.size(); pos++)
{
DCS_LOG_DEBUG("FOUND AFTER POS INDEX " << order[pos]);
}
}
checks
order[i1] == "D"for truth. If that is not true it then checks"W"for truth. That is always true and so the compiler can probably work out that this test always evaluates to true.What you really mean is