Computers and Technology

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.

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 23:00, fluffy374747
The animal classthis class represents a an animal residing at a zoo. it has a weight (in pounds),height (in inches), a name, and a color. the methods in the class include constructors, getters, and a tostring. you will finish the implementation of these methods. referto the code documentation.1.getters: you will need to implement getter methods. these get a value (froma member variable) in the animal class. you will make a getter method toreturn each variable (weight, height, name, color). reference getname if youare having issues.2.tostring: you will need to finish the tostring method. this returns a stringcontaining information about an animal. the output string should be of theformat: ” (name) , a ( color )â’colored animal . ( weight ) pounds , ( height ) inches .\n”the height and weight are formatted to 1 decimal place. recall from lab 1how to format strings neatly using string. see the reference sectionfor more about string. format.
Answers: 2
image
Computers and Technology, 22.06.2019 17:00, juandguardado7045
Your company has 1,500 desktop computers running windows 7. you want to upgrade them to windows 10. which type of microsoft license would be best suited in this situation?
Answers: 3
image
Computers and Technology, 24.06.2019 14:30, ari313
Two students are discussing the flow of electricity. student a says that voltage is a measure of the amount of electron flow in a circuit. student b says that power is the product of voltage and current. which of the following statements is correct? a. only student a is correct b. only student b is correct c. both of the two students are correct d. neither of the two students is correct
Answers: 1
image
Computers and Technology, 24.06.2019 23:00, lovelifekristy
Aselect query joins tables together by their a. table names. b. primary keys. c. first entries. d. field names.
Answers: 2
Do you know the correct answer?
For this assignment, you must know how to create a container class template and write its constructo...

Questions in other subjects:

Konu
Mathematics, 10.10.2021 20:20