Create a class template called GenericVector. The class should have the following members:

  • Private Data Member: vec (a vector of type parameter).
  • Public Member Functions:
    • push: This public function should accept an argument and insert its value at the end of the vector. (Hint: can use vectors push_back method)
    • last: This function should accept no argument and return the value of the last element of the vector.
    • print: This function will print all the elements in vector. Use a stream manipulator to ensure that at most 2 digits are printed after decimal.

After you have created the class template, develop a test program (containing main() ) that will do the following:

  • declare an object of GenericVector where the type parameter will be replaced by double.
  • enter at least 3 double values into the vector of object created in (a).
  • use the last function to print the last element of the vector.
  • print all the elements in the vector.
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.