next up previous
Next: How do I put Up: What are templates? Previous: How do I specify

How do I specify a template method?

In a header (.h file) :
class   Vector
{
  int     array[3];

  template <class TVECTOR2> 
  void  eqAdd(TVECTOR2 v2);
};

template <class TVECTOR2>
void	Vector::eqAdd(TVECTOR2 a2)
{
  for (int i(0); i < 3; ++i) array[i] += a2[i];
}



Alexis Angelidis (PhD) 2005-01-11