无法从队列中删除条目并将其添加到堆栈中

时间:2017-10-30 06:39:13

标签: c++ list stack queue

更新

我想要完成的是一旦从队列中删除了一个条目,它就会被添加到一个堆栈中。 dequeue和push函数可以单独工作,但我也不确定如何将函数添加到堆栈中。它似乎正在踩过我在队列函数中创建的if语句,将信息推送到堆栈。

bool Queue::dequeue(qInfo& aInfo)
{

//Check if the queue is empty
if(isEmpty())
    return false;
else
{
    qNode* temp = front;

    //Check if this is the Only Node
    if(front == rear)
        front = rear = NULL;
    else
        front = front->next;

    temp->next = NULL;
    aInfo = temp->item;
    if(aInfo.getCoupons(true))
    {
        cout << "The code made it this far." << endl;       //Test to see if code stepped through
        char name[100];
        char email[100];
        Stack sAdd;

        cout << "The code made it this far." << endl;       //Test to see if code stepped through

        aInfo.getFname(name);
        aInfo.getEmail(email);

        sInfo newSinfo(name, email);
        sAdd.push(newSinfo);
        cout << "The code made it this far." << endl;       //Test to see if code stepped through
    }

    delete temp;
    return true;
}

0 个答案:

没有答案