subject

For this assignment, you must know how to create a container class template and write its constructors, including a copy constructor and overload the assignment operator '=' and [] operator. You may need to review these in object oriented programming class (Co Sci 840).

Define a class template called List with size and a pointer to an array of data of generic type.

Include a default constructor, a constructor that takes size and allocates memory for an array of size elements of generic type, a copy constructor and a destructor. Define these member functions outside the class definition. When doing so, you must specify the type with:

template //before the function definition

And, you must precede the class with the generic type:

List::List();

Include also resize() to resize the array to a given size and overload operator [] and the assignment operator (=).

Also, define two insert() member functions: insert_front() that inserts an element at the front of the array and insert_back() that inserts an element at the back of the array. To accomplish this, you must first resize the array by calling resize(), which will copy all old elements into the newly instantiated array and then insert the value to be inserted.

Also, define two remove() member functions: remove_front() that removes an element from the front and remove_back() that removes an element from the back. Again, you must resize and then copy all elements except the one being removed.

You will see that while a dynamic array such as this makes it easy to access any given element through its indexes, it's not well suited for insertion and deletion of an element. These operations take too many operations to accomplish.

Test the class in main() with both double type and Date type, where Date is a structure with month, day and year as its integer fields. Instantiate a List of size 5 of both types and have the user enter 5 elements. Display the list.

Then, resize to size 10 and read another 5 elements of both types and print the list again.

Then, test the insert_front() and insert_back(), as well as remove_front() and remove_back() functions by reading a value from the user to insert at front and one to insert at back and print the list, and then remove from both front and back and print the list each time to confirm the operation.

Upload and submit two cpp files: one containing main() and one the function definitions, as well as a header file (.h) for the structure and class definitions.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 09:00
The first screen you see when you open word2016 what is called?
Answers: 1
question
Computers and Technology, 23.06.2019 19:30
What are loans to a company or government for a set amount of time
Answers: 1
question
Computers and Technology, 24.06.2019 07:50
Write a defining table and then a program that determines if you can sleep in or not. your program should get all its input from your computer’s clock. on all weekdays (monday through friday) that are not holidays, your program should output “get up! ” on all other days (weekends and holidays), your program should output “sleep in.” the three holidays that your program must check for are january 1 (new year’s day), july 4 (u.s. independence day), and december 25 (christmas). you don’t need to include other holidays in your program because most other holidays do not occur on a fixed day each year.
Answers: 1
question
Computers and Technology, 24.06.2019 09:30
Retype the statements, correcting the syntax errors. system.out.println("num: " + songnum); system.out.println(int songnum); system.out.println(songnum " songs"); note: these activities may test code with different test values. this activity will perform two tests: the first with songnum = 5, the second with songnum = 9. see how to use zybooks.
Answers: 1
You know the right answer?
For this assignment, you must know how to create a container class template and write its constructo...
Questions
question
Mathematics, 19.09.2019 00:30
question
Mathematics, 19.09.2019 00:30
question
History, 19.09.2019 00:30
Questions on the website: 13722363