A template type is a special type that can take on different types when the type is initialized.

std::vector uses a template type

Untitled

std::vector

Standard library class that provides the functionality of a dynamically growing array with a templated type.

Template Type

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.

The code above can accept int, string, whatever if comparision could work.

Untitled

Dynamic size of array is not possible.

Dynamic size of array is not possible.