Check out example codes for "how to write a template c++". It will help you in understanding the concepts better.

Code Example 1

template class  Graph<string>;

Code Example 2

template <class T>
void swap(T & lhs, T & rhs)
{
 T tmp = lhs;
 lhs = rhs;
 rhs = tmp;
}

void main()
{
  int a = 6;
  int b = 42;
  swap<int>(a, b);
  printf("a=%d, b=%d\n", a, b);
  
  // Implicit template parameter deduction
  double f = 5.5;
  double g = 42.0;
  swap(f, g);
  printf("f=%f, g=%f\n", f, g);
}

/*
Output:
a=42, b=6
f=42.0, g=5.5
*/

Code Example 3

template <class myType>
myType GetMax (myType a, myType b) {
 return (a>b?a:b);
}

Learn ReactJs, React Native from akashmittal.com