#include #include "stack_solution.h" Stack::Stack() : first(nullptr) {} Stack::~Stack() { delete first; } bool Stack::empty() const { return first == nullptr; } void Stack::push(Stack_Data const& i) { first = new Element(i, first); } Stack_Data Stack::pop() { if ( empty() ) { // std::cerr << "empty stack" << std::endl; throw std::logic_error("empty stack"); } else { Element* victim{ first }; Stack_Data data = victim->data; first = victim->next; victim->next = nullptr; delete victim; return data; } }