c++ while loop doesn't exit on false condition -


I'm having a problem with my code which results in a run time error. To debug the code, I have thrown some seats in the statement so that it can be detected as to how the code runs correctly. Based on the output it looks like when the situation of the situation breaks down, when it evaluates the situation false, but I can not see how it is possible. Here's the code:

var declarations:

  queue < String & gt; New order; Stack & LT; Of vector & lt; Four & gt; & Gt; Opstack; Four symbols;   

The stuff pops up the stack and the queue, then this code reaches:

  while (opstack.empty () == incorrect) {if (Opstack.top () [1]! = 'L') {cout & lt; & Lt; "Stack is empty ?:" & lt; & Lt; Opstack.empty () & lt; & Lt; Endl; Symbol = opstack.top () [0]; NewOrder.push (symbol); OpStack.pop (); Cout & lt; & Lt; "Popped stack;" & Lt; & Lt; Endl; Cout & lt; & Lt; "Stack is empty ?:" & lt; & Lt; Opstack.empty () & lt; & Lt; Endl; } And {break} }} Cout & lt; & Lt; "Made it while loop"; If (opstack.top () [1] == 'L') {opStack.pop (); } And {errorEncountered = true; }   

This output is:

  the stack is empty ?: 0 pop stack; The stack is empty: 1 run out (Exhaust Price 1, Total Time: 1s)   

So, depending on the output, the stack is empty at the end of the loop. This makes the position of the loop false, but the program fails before the loop turns out. How can that be possible? What is there to do this in a manner of stack?

While the loop exits on false bet. I was not debugging properly, and he noticed me on the wrong part of the code.

The problem is what really happens after the last cot. After that statement, if (opstack.top () [1] == 'L') {, attempts to get the top object from empty stack and goes away due to failure .

But how is this possible, because we do not ever see "taking time off of loop" in the output? The reason for this is that the last to the output is never lost before the program crashes. I used the & lt; & Lt; The endl is added, and this is the move "it was turned out of loop" was displayed and I was able to solve the real problem in the program. Thanks for (@ if (opstack.empty =) false) {// second if-else set} )

letting me know that in my original but poorly formatted question Was not being flying :)

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -