Take the code from the integer_vector.cpp program, and modify it to create a program (called generic_vector.cpp) that does that following:

1.Uses templates in order to allow the BasicVector class to not be limited to just containing integers

  • The template will allow you to substitute a placeholder label in the following parts of the code:
    • The data type of the data member field
    • The value parameter in the push_back and insert functions
    • The return type of the at, front, back, and [] functions
    • Logic in the resize and the constructors that dynamically allocate data

2.Modify the interactive prompt to use templates in the following way:

  • Before asking for the starting capacity, prompt the user to specify what data type they want the vector to store in data
    • 1 for int
    • 2 for float
    • 3 for double
    • 4 for string
    • 5 for bool

Expected prompt/input with sample output

Specify what data type to store in vector:
1) int
2) float
3) double
4) string
5) bool

> 3
Enter starting capacity of double vector: 10

Now accepting commands (quit to exit program):
> push 10.4
> size 1
> capacity 16
> print elements(1): 10.4
> quit

Exiting program.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.