[Solved]Chapter 8 Discussed Vectors Like Arrays Grow Size Suppose Vectors Defined C Define Class Q37213093
In Chapter 8 we discussed vectors, which are like arrays thatcan grow in size. Suppose that vectors were not defined in C++.Define a class called VectorDouble that is like a class for avector with base type double. Your class VectorDouble willhave a private member variable for a dynamic array ofdoubles. It will also have two member variables of typeint; one called maxCount for the size of the dynamic arrayof doubles; and one called count for the number of arraypositions currently holding values. (maxCount is the same as thecapacity of a vector; count is the same as the size of avector.)
If you attempt to add an element (a value of typedouble) to the vector object of the class VectorDouble andthere is no more room, then a new dynamic array with twice thecapacity of the old dynamic array is created and the values of theold dynamic array are copied to the new dynamic array.
Your class should have all of the following:
Three constructors: a default constructor that creates a dynamicarray for 50 elements, a constructor with one int argumentfor the number of elements in the initial dynamic array, and a copyconstructor.
A destructor.
A suitable overloading of the assignment operator =.
A suitable overloading of the equality operator ==. To be equal,the values of count and the count array elements must be equal, butthe values of maxCount need not be equal.
Member functions push_back, capacity, size, reserve, and resizethat behave the same as the member functions of the same names forvectors.
Two member functions to give your class the same utility as thesquare brackets: valueAt(i), which returns the value of the ithelement in the dynamic array; and changeValueAt(d, i), whichchanges the double value at the ith element of the dynamicarray to d. Enforce suitable restrictions on the arguments tovalueAt and changeValueAt. (Your class will not work with thesquare brackets. It can be made to work with square brackets, butwe have not covered the material which tells you how to dothat.)
Teacher Instruction:
For this project, you need to complete all of:
- The header for the VectorDouble class
- The implementation of the VectorDouble class
- A test program that exercises the VectorDouble class
I used the Vector homework problem of the previous lesson as thestarting point for a test program for the VectorDouble class butyou are welcome to write something new. The VectorDouble class wewrite should behave just like a Vector. And like all good classes,this class should throw exceptions to the main program when itencounters errors. You may throw simple exceptions, such asintegers, but I do want your class to throw exceptions rather thanprint out messages. Leave all the cout statements up in the mainprogram.
Here is an example:

HACSC160 CSC ALesson 11 Hw11lesson11-694-1.exe esting contructors The capacity of new_vector is :50 The size of new_vector is :0 The capacity of new_vecto2 is:33 The size ofnew_vector2 is:0 The capacity of new_vector3 is :33 The size of new_vector3 is :0 Testing member functions: The new capacity of new_vector is:33 The new size of new_vector is:0 The first value in new_vector4 is 21 The new first value in new_vector4 is now:23 Uectors 4 and 3 are not equal The capacity of new_vector4 is:50 After a call to reserve the capacity of new_vector4 is 52 the size of new_vector4 is:1 After a call to resize the capacity of new_vector 4 is:3 Testing expanding array: The capacity of new_vector is :132 The size of new_vector is:99 Press any key to continue .. . Show transcribed image text HACSC160 CSC ALesson 11 Hw11lesson11-694-1.exe esting contructors The capacity of new_vector is :50 The size of new_vector is :0 The capacity of new_vecto2 is:33 The size ofnew_vector2 is:0 The capacity of new_vector3 is :33 The size of new_vector3 is :0 Testing member functions: The new capacity of new_vector is:33 The new size of new_vector is:0 The first value in new_vector4 is 21 The new first value in new_vector4 is now:23 Uectors 4 and 3 are not equal The capacity of new_vector4 is:50 After a call to reserve the capacity of new_vector4 is 52 the size of new_vector4 is:1 After a call to resize the capacity of new_vector 4 is:3 Testing expanding array: The capacity of new_vector is :132 The size of new_vector is:99 Press any key to continue .. .
Expert Answer
Answer to In Chapter 8 we discussed vectors, which are like arrays that can grow in size. Suppose that vectors were not defined in… . . .
OR

