Question: Declare and implement a class to represent a list of integers, called IntList. Use an array of integers of size 100 to store the values
Declare and implement a class to represent a list of integers, called IntList. Use an array of integers of size 100 to store the values in the list. Use an integer variable named num to store the number of elements currently in the list. Include the following functions in your class:(C++)
a no-argument constructor that sets up an empty list.
a void function add(x) that adds a new value, x, to the end of the list. If adding the element would exceed the lists capacity, this function should output an error message.
a function sort(a, size) that takes an array of integers (a) and its size and rearranges the items in the array so that they are in ascending order. You may use any algorithm to sort the array. It should not change the order of the elements in the list member. A function median() that returns the median value of the list of integers. If the values are in order from smallest to largest, the median is the middle value. If the list contains an even number of values, the median is the average of the two middle values. If the list is empty, the median is 0. This function should not change the order of the elements in the list member. For example, if the list contains{3,5,8,4,9,6,7} the median is 6. If the list contains {6,7,8,9,1,2,3,4} the median is 5. If the list contains {7,8,9,10,1,2,3,4} the median is 5.5.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
