Question
C++ language: Create a class List. The class has the following data members: numItems as an integer list as a pointer to an integer array
C++ language:
Create a class List. The class has the following data members:
numItems as an integer
list as a pointer to an integer array
objectCount as a static integer, to keep track of the number of objects created.
The class has following function members:
1- A constructor that takes in one parameter of type integer to set the numItems. In the constructor, use the pointer list to create an array dynamically of size numItems and initialize it to a DEFAULT_VALUE (0).
2- A function readList to fill the List object with integer values from the user.
3- A function print to print the list items separated by spaces.
4- A function getAverge to return the average of the list items.
5- A function getObjectCount to return the objectCount.
6- A copy constructor that copies all the data members and list values to the newly created List object (copy the values in the array not the address).
7- Overload the operators +, -, =, ==, ++ such that:
a. The statement list1 + list2 will return a List object that each element of it is the sum of the corresponding elements in list1 and list2.
b. The statement list1 - list2 will return a List object that each elements of it is the result of subtracting the elements of list2 from the corresponding elements in list1.
c. The statement list1 = list2, will copy the elements in list2 to the corresponding elements in list1.
d. The statement list1 == list2, will compare the corresponding elements in list1 and list2. It returns true if all corresponding elements are similar and false otherwise.
e. The statement list1++ increments all the elements of list1 by one.
In the main function, create a List object of 10 elements. Display the elements in the list (which will be of course empty to start- has the default value 0). Then go into a loop that display a menu where you let the user pick an operation to do on the list (one of the functions in part 1: #2 #7e). Do the operation, display any results that are appropriate so the tester can see that the operation was done. Include an option to quit when the user wants to. To get the full points for an operation, your menu must work for that option and not simply have the function listed in the menu or implemented in theory.
For the operations that require another operand such as copy constructor, +, -, ==, create another List object, call readList to let the user fill the second List object with numbers from the user. Then apply the operation and display the result.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started