Error: deque iterator not dereferenceable

前端 未结 3 1460
予麋鹿
予麋鹿 2021-01-20 05:07

I\'m trying to create a program that converts an arithmetic expression from infix to postfix form. As long as I don\'t call the \"infixToPostFix\" function, the program runs

3条回答
  •  我在风中等你
    2021-01-20 06:10

    stack is implemented using container, since stack is container adaptor, by default deque is used. In probably one line of your code - you call pop/top on empty stack, that is not allowed.

    trace show, that error is after Token +. Problem is here:

       else if (token.getType() == OPERATOR)
        {
            Token topToken = stack.top();
    

    You try to top from empty stack, since stack in case, where is only NUMBER token before OPERATOR token, is empty.

提交回复
热议问题