Take the following code and look closely at the bold line:
It simply pops something off the top of the stack, but it causes a crash. I've tried using a try-catch clause and it still gives me the same thing without an error message. I don't see why this would cause a problem, since I'm checking the size first.Code:if (function_stack.size() > 0)
{
string::size_type op_prec_2 = function_precedence[ function_operators.find(function_stack.top()) ];
string::size_type op_prec_1 = function_precedence[ function_operators.find(eq[counter]) ];
if (op_prec_2 <= op_prec_1)
{
ostringstream oss;
oss << function_stack.top();
output_queue.push( oss.str() );
if (function_stack.size() > 0)
{
function_stack.pop();
}
}
}
Also, if I change this line:
if (op_prec_2 <= op_prec_1)
to this:
if (op_prec_2 >= op_prec_1)
it works fine, but for some reason the top line causes the stack not to be able to pop();
Does anyone have a clue why this is happening?
PS: I've done cout statements all through out the program. Everything is good.
