logical or expression c++

Posted by user1870181 on Stack Overflow See other posts from Stack Overflow or by user1870181
Published on 2012-12-02T11:02:38Z Indexed on 2012/12/02 11:03 UTC
Read the original article Hit count: 158

Filed under:
|
|
|

I have a problem using the Logical OR operator in C++. The problem is coming that the right-side expression is not evaluated if the left-side is true. I have two deque-s and I need to popLeft from them with a while, but if I can pop from the first deque, I don't pop from the second because is not evaluated, by the OR operator. How can I overcome this problem. Here is the piece of code:

while( D.popLeft( k ) || E.popLeft( m ) )
{
    if( k < m )
    {
      C.pushRight( k );
      E.pushLeft( m );
    }
    else
    {
      C.pushRight( m );
      D.pushLeft( k );
    }
}

© Stack Overflow or respective owner

Related posts about c++

Related posts about c