Question: C++ Create a Stack Linked List Create a Stack Linked List of todo items using the following struct struct TodoItem { std::string todo; }; Do

C++ Create a Stack Linked List

Create a Stack Linked List of todo items using the following struct

struct TodoItem { std::string todo; };

Do NOT add a main method to any of your submitted files. DO write your own test drivers to test your code, but do not submit them. Your code needs to be readable, efficient, and accomplish the task provided. Make sure you delete your dynamically allocated memory in the appropriate methods! When working with array-based implementations, there is a max size available (set to 5 for this assignment in the header files). Display an error message if attempting to add to a full array: Stack full, cannot add new todo item. Or Queue full, cannot add new todo item. Note this does not apply to linked-list implementations. If the stack or queue is empty when you try to pop or peek it, display an error message: Stack empty, cannot pop an item. Stack empty, cannot peek. Queue empty, cannot dequeue an item. Queue empty, cannot peek. Make sure your code is commented enough to describe what it is doing. Include a comment block at the top of all .cpp files with your name, assignment number, and course instructor, and anyone you worked with. You must implement the functions as specified. You do not need any additional functions. Each .hpp file has one or more getter methods that are defined in the header. You do not need to implement these. Use the following code for your header files, and name them as indicated. DO NOT MODIFY.

Header file:

#ifndef HW4_TODO_STACKLINKEDLIST #define HW4_TODO_STACKLINKEDLIST #include struct TodoItem { std::string todo; TodoItem *next; }; class TodoStackLinkedList { public: TodoStackLinkedList(); ~TodoStackLinkedList(); bool isEmpty(); void push(std::string todoItem); void pop(); TodoItem* peek(); TodoItem* getStackHead() { return stackHead; } private: TodoItem* stackHead; // pointer to the TodoItem that will be popped next }; #endif

Will give thumbs up for correct code with comments to explain what is going on. Thank you.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!