#include "header.h" //constructor Stack::Stack() { } //destructor Stack::~Stack() { } //adds new node to stack void Stack::push(std::string name) { //new is the C++ version of new Node *newNode = new Node; //init values newNode->name = name; //assigns the current stack to "next" //making newNode on top of stack newNode->next = value; //value is assigned to newNode value = newNode; } std::string Stack::pop() { //return value std::string tstring; //stack is not null if (value) { //assign top of stack to popped Node *popped = value; //return value tstring = popped->name; //top value of stack is now next value = value->next; //deletes popped, deallocating the memory. delete popped; } //stack is empty else { std::cout << "Stack is Empty" << std::endl; tstring = "Empty"; } return tstring; } //this returns string name of the top value void Stack::peek() { if (value != NULL) std::cout << value->name << std::endl; } //prints all values of stack, starting at the top void Stack::printStack() { //temp node is assigned to our stack Node * list = value; //traverses through list and prints value while(list) { std::cout << list->name << "--> "; list = list->next; } std::cout << "End of Stack" << std::endl; } //checks if stack is empty bool Stack::isEmpty() { if (value) return false; else return true; }