A template type is a special type that can take on different types when the type is initialized.
std::vector uses a template type
Standard library class that provides the functionality of a dynamically growing array with a templated type.
include <vector>
std::vector<T> v;
::push_back(T);
v.push_back(4)
::operator[] (unsigned pos);
::size()
When initilizing a templated type, the template type goes inside of <> at the end of the type name
std::vector<char> v1;
C++ allows for us to use the power of templates in building our own classes.
template <typename **T**>
class List{
...
private:
**T** data_;
};
template <typename T>
int max(T a, T b) {
if (a > b) { return a; }
return b;
}
Templated variables are checked at compile time, which allows for errors to be caught before running the program.
Dynamic size of array is not possible.