Templates in C++
cpp templates
template <class I, class v> class Lattice
{
// private and public code here.
// constructors, building a lattice, navigating.
}
template <class Type= double> class Range
{
// default type is double.
private:
Type lo:
Type: hi;
Range(); // constructor
public:
Range(const Type& low, const Type& high);
Range(const Range<Type>& ran2);
virtual ~Range();
// modifier functions.
// setters
void low(const Type& t1);
void high(const Type& t1);
// getters
Type low() const;
Type high() const;
Type length() const;
bool left(const Type& value) const;
bool right(const Type& value) const;
bool contains(const Type& value) const;
Range<Type>& operator = (const Range<Type>& ran2);
}
Using the template class.
A template class is a type. In constrast to non-templated classes, it has no instances as such.