Final answer:
To transform your Vector class into a generic template, replace all 'int' types with 'T' and ensure all methods are included in the header file.
Step-by-step explanation:
The correct answer is to create a template class in C++ that will allow you to have a generic vector, rather than one specific to int types. To transform the provided Vector class into a templated version, you'll need to replace all instances where the data type int is specified with T, which will be the template parameter.
For example, you'll change the declaration from int *data_ptr to T *data_ptr, and likewise for all function parameters and return types that use int.
All method implementations will also need to be included within the header file, as template classes must be fully defined in each file they are used. This is because C++ templates are compiled when instantiated, and therefore their implementation always needs to be available to the compiler.
In this lab, the goal is to make the Vector class generic by using a class template called <T>. To achieve this, you need to replace all references to the type of elements (int) contained in the array with the template parameter T. This will allow the Vector class to hold elements of any type.
The implementation notes mention that all template definitions must be inline within a single .h file. This means that the template definition for the Vector class should be included in the Vector.h file.
Once you have made the necessary changes to the Vector class, you can use the provided test driver, testVector.cpp, and the test framework in test.h to rigorously test your project.