c ++中的双重链接列表...前一个指针在第二次迭代中显示垃圾值?

时间:2016-03-31 06:44:32

标签: c++

1 + 3-2 这是我从文件中读取并尝试评估的表达式 当做1 + 3我得到我的临时指针+和temp->前面有值1并且一切正常然后我得到4-2但是当我评估这个并得到我的临时指针 - temp-> previous显示垃圾值而不是显示4 .....请帮助

void evaluate(list *temp, char operator)
 {
    temp = head;
    while (temp != nullptr)
    {


   if (temp->next->operatorval == operator)
        {

    if (oper == '/')
    temp->previous->floatval = temp->previous->floatval / temp->next->floatval;

    else if (oper == '*')
    temp->previous->floatval = temp->previous->floatval * temp->next->floatval;

    else if (oper == '+')
    temp->previous->floatval = temp->previous->floatval + temp->next->floatval;

    else if (oper == '-')
    temp->previous->floatval = temp->previous->floatval - temp->next->floatval;

    temp = temp->previous;

            removeNext(temp, temp->next, 1);
            removeNext(temp, temp->next, 2);



        }


        temp = temp->next;
    }


}

0 个答案:

没有答案