#include #include #include "stack.h" Stack::Stack() : first{nullptr} {} std::string Stack::to_string() const { std::string s{"[ "}; Book* curr{first}; while ( curr ) { s += curr -> name; s += " "; curr = curr -> next; } s += "]"; return s; } void Stack::push(std::string t) { first = new Book{t, first}; } void Stack::pop() { if( first ) { Book* tmp{first->next}; first -> next = nullptr; delete first; first = tmp; } } std::string Stack::top() const { if( first ) { return first -> name; } else { return "Empty"; } }