|
|
For example, consider a Vector template:
template <class T> class Vector { int cursize; T* ptr; void grow(); public: Vector(); ~Vector(); T& operator[](int); };
This template takes one type argument T, has two private data members cursize and ptr, and one private member function grow. There are also a public constructor and destructor and one function operator[](int).
Suppose that you have some class A and you want to use a vector of class objects in your application. To do this, you might say:
void f() { Vector<A> x; A a, b;x[17] = a; b = x[23]; }
Vector<A> is a ``template class'', a combination of a template with specific argument types. This is an instantiation.