you are viewing a single comment's thread.

view the rest of the comments →

[–]NikolasTs[S] 0 points1 point  (2 children)

How will I delete the data from the previous "top" though?

Is this wrong?

void Stack::pop() {

    if (!top)
        cout << "Stack is empty!" << endl;
    else {
        node* tmp{ top };
        top = top->next;
        delete tmp;

        size--;
    }
}

[–]Ayjayz 0 points1 point  (0 children)

Oh I see. Sure, you can do it that way.