Question: Chapter 8 discussed vectors, which are like arrays that can grow in size. Suppose that vectors were not defined in C++. Define a class called

 Chapter 8 discussed vectors, which are like arrays that can grow

in size. Suppose that vectors were not defined in C++. Define a

Chapter 8 discussed vectors, which are like arrays that can grow in size. Suppose that vectors were not defined in C++. Define a class called VectorDouble that is like a class for a vector with base type double. Your class VectorDouble will have a private member variable fora dynamic array of doubles. It will also have two member variables of type int; one called max count for the size of the dynamic array of doubles; and one called count for the number of array positions currently holding values. (max count is the same as the capacity of a vector count is the same as the size of a vector.) If you attempt to add an element (a value of type double) to the vector object of the class VectorDouble and there is no more room, then a new dynamic array with twice the capacity of the old dynamic array is created and the values of the old 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 dynamic array for 50 elements, a constructor with one int argument for the number of elements in the initial dynamic array and a copy constructor . A destructor . A suitable overloading of the assignment operator rloading of the equality operator To be equat the valtes of count and the count array elements must be equal, but the values of max count need not be equal . Member functions push back, capacity, size, reserve, and resize thai belhave the same as the member functions of the same names for vectors . Two member functions to give your class the same utiluity as the square brackets value at(). which returns the value of the ith element im the dynamic aray: and change value at(d, D, which changes the double yalue ar the ith clement of the dynamic

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!