In this homework, you will program a singly-linked list of integers similar to the linked stacks from lecture. You will use modern C++ memory management via the unique_ptr class found in the <memory> library. You can use the ModernLinkedStack as inspiration, but will need to add a few more methods to it.
Assignment
Copy the ō°les ModernLinkedList.h and ModernLinkedList.cpp from the GitHub repository, then make a new project with those ō°les. Review the ō°les so you’re clear on what instance variables and methods are expected on this type, then begin to implement the methods from the .h ō°le as described. Some notes:
- The procedure for adding a new element can be diō°erent depending on whether the list is currently empty. You can use the current mSize to determine if the list is empty.
- The existing PrintList and PopBack functions shows an example of ō°walkingō° through the nodes of the list. You will need to do something similar for PushBack, Insert and RemoveAt, and operator[]. (operator[] is equivalent to the ō°getō° function from Java’s linked lists ō° it returns the data element at the given index.)
- You should write a main to test your list. Add and remove some elements, and use PrintList to periodically check the correctness of the list.
- If you do this correctly, you will never have to use new or delete ō° that’s the entire purpose of the unique_ptr type.
Deliverables Hand in:
1. ModernLinkedList.cpp and your main.cpp. Submit to Dropbox.
1



