Whats the syntax / semantics for a “class template”?
Consider a container class Array that acts like an array of integers: // This would go into a header file such as “Array.h” class Array { public: Array(int len=10) : len_(len), data_(new int[len]) { } ~Array() { delete [] data_; } int len() const { return len_; } const int& operator[](int i) const { return data_[check(i)]; } int& operator[](int i) { return data_[check(i)]; } Array(const Array&); Array& operator= (const Array&); private: int len_; int* data_; int check(int i) const { if (i < 0 || i >= len_) throw BoundsViol(“Array”, i, len_); return i; } }; Just as with swap() above, repeating the above over and over for Array of float, of char, of String, of Array-of-String, etc, will become tedious. // This would go into a header file such as “Array.h” template