Question: Overvievw A vector is a container that can be treated like a normal array (created without using the new keyword) but also allows for dynamic

 Overvievw A vector is a container that can be treated likea normal array (created without using the new keyword) but also allowsfor dynamic resizing if the vector runs out of capacity to storenew data. How is this possible? A vector is just an abstractionthat performs dynamic memory allocation behind the scenes, but is presented in

Overvievw A vector is a container that can be treated like a normal array (created without using the new keyword) but also allows for dynamic resizing if the vector runs out of capacity to store new data. How is this possible? A vector is just an abstraction that performs dynamic memory allocation behind the scenes, but is presented in a way that is familiar to using an array, as well as providing additional functionality When instantiated, a vector will create a dynamically allocated array of the requested type. The size of the array is typically passed by the user, or handled with default values. Vectors allow for the use of array notation with braces as well as with an at function to access array elements. You can also use the front and back functions to retrieve the appropriate ele ments. The push back and insert functions should be used to put new information inside the vector, and incrementally increase the size of the vector. at and [ should only be used to reassign the value of an element that has been pushed into the function with push back To allow for reassignment as well as access, the above functions return references to the requested element, they do not simply return the value at that index. There are other functions that vector provide that will be discussed in the sections below Program 1. (80 points) Integer Vector Write a program (called integer vector.cpp) that does the following: 1. Implement a class called BasicVector that: Contains private member fields for: o data: integer pointer that is used to point to a dynamically allocated 1D integer array o vector size: the current number of items in data o vector_capa city : the maximum number of items that can be contained in data before it needs to be resized Contains the private member function: o resize: No return type (void), no parameters. Dynamically creates a new 1D array with twice the capacity of the existing array. Copy all of the existing elements over into the new array, update vector_capacity, use a temporary variable store the current address of data and delete to free the old array Point data to the new array Contains public member functions o at returns an int reference to the arra y element specified. Has conditional logic that prevents using an index larger than the vector_size of the BasicVector object by calling exit 1 to terminate the program. Accepts a single parameter, int index o operatorll returns an int reference to the array element specified. Has conditional logic that prevents using an index larger than the vector size of Overvievw A vector is a container that can be treated like a normal array (created without using the new keyword) but also allows for dynamic resizing if the vector runs out of capacity to store new data. How is this possible? A vector is just an abstraction that performs dynamic memory allocation behind the scenes, but is presented in a way that is familiar to using an array, as well as providing additional functionality When instantiated, a vector will create a dynamically allocated array of the requested type. The size of the array is typically passed by the user, or handled with default values. Vectors allow for the use of array notation with braces as well as with an at function to access array elements. You can also use the front and back functions to retrieve the appropriate ele ments. The push back and insert functions should be used to put new information inside the vector, and incrementally increase the size of the vector. at and [ should only be used to reassign the value of an element that has been pushed into the function with push back To allow for reassignment as well as access, the above functions return references to the requested element, they do not simply return the value at that index. There are other functions that vector provide that will be discussed in the sections below Program 1. (80 points) Integer Vector Write a program (called integer vector.cpp) that does the following: 1. Implement a class called BasicVector that: Contains private member fields for: o data: integer pointer that is used to point to a dynamically allocated 1D integer array o vector size: the current number of items in data o vector_capa city : the maximum number of items that can be contained in data before it needs to be resized Contains the private member function: o resize: No return type (void), no parameters. Dynamically creates a new 1D array with twice the capacity of the existing array. Copy all of the existing elements over into the new array, update vector_capacity, use a temporary variable store the current address of data and delete to free the old array Point data to the new array Contains public member functions o at returns an int reference to the arra y element specified. Has conditional logic that prevents using an index larger than the vector_size of the BasicVector object by calling exit 1 to terminate the program. Accepts a single parameter, int index o operatorll returns an int reference to the array element specified. Has conditional logic that prevents using an index larger than the vector size of

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!