Question: Using C++ use pointers with dynamic memory, templates, binary files and exception handling to build a multi-purpose, generic, Single Linked List. Anytime you are using
Using C++
use pointers with dynamic memory, templates, binary files and exception handling to build a multi-purpose, generic, Single Linked List. Anytime you are using dynamic memory, you should have a Copy Constructor, overloaded Assignment Operator, and a Destructor. Though this will be similar in functionality to the C++ Standard Template Library (STL) forward_list, you will create your own using pointers (instead of forward_list, list or vector). Create a Student struct with a name[20] and a student id. Overload the << for a Student Create a Node with templated data (so that you can have Nodes of any legitimate data type). Nodes also have pointers to other Nodes (that must be templated). Structs are acceptable means of describing Nodes. Create a templated List class (templated with the same type of data that is used in your Node). This class should maintain a head pointer to templated Nodes. This is the start of your linked list.
This class should have the following member functions: Appropriate Constructors
Appropriate Constructors Copy Constructor - Used to give the values of an already declared list to another list - Deep Copy - Set the calling objects headPtr to nullptr - Copy every node from what is in the parameter to the object created with the Copy Constructor. Consider using your push_back function. Overloaded Assignment Operator - Used to assign the values of one already declared list to another already declared list - Deep Copy - Delete anything that might be pointed to by headPtr (Considering using your pop_back function) - Copy every node from what is in the parameter to the called object created by the assignment (again consider using your push_back function) - Return the value of what is pointed to (return *this). Remember the this pointer refers to the object that called the member function clear - Delete ALL of the nodes in the linked list - If you are not concurrently enrolled in Data Structures, you can send your instructor an email asking for the code to the clear function Destructor - Get your clear working firstthen AND only then should you call clear in your Destructor push_front and push_back: Pushes data (not Nodes) into the front or back of the list. Remember that this is an array of characters, so you will #include
printList: Function should be called printList and implemented with a loop and the << operator for the data. (<< does not work well when templated, so you cant overload that operator for the list) students.dat: Ashly o Jennifer Xavier r M
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
