Question: In C++ Create a class template called GenericVector. The class should have the following members: (Reference: Fig 18.2 and Fig 18.3) a) Private Data Member:
In C++






Create a class template called GenericVector. The class should have the following members: (Reference: Fig 18.2 and Fig 18.3) a) Private Data Member: vec (a vector of type parameter). b) Public Member Functions: push: This public function should accept an argument and insert its value at the end of the vector. (Hint: can use vector's 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 al the elements in vector c)After you have created the class template, develop a test program (containing main0) that will do the following: i. declare an object of Generic lector where the type parameter will be replaced by double. ii. enter at least 3 double values into the vec data member of object created in (i). iii. use the last function to print the last element of the object's vec data member. iv. use the print function to print all elements of the object's vec data member. use a stream manipulator to ensure that 2 digits are printed after decimal
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
