1. Full Program - C++ Class Templates: 
  2.  
  3. //C++_Class_Templates.cpp 
  4.  
  5. #include <iostream.h> 
  6. #include <vector> 
  7.  
  8. template <typename T> 
  9. class MyQueue 
  10.      std::vector<T> data;  
  11.    public
  12.      void Add(T const &); 
  13.      void Remove(); 
  14.      void Print(); 
  15. }; 
  16.  
  17. template <typename T> void MyQueue<T> ::Add(T const &d) 
  18.      data.push_back(d); 
  19.  
  20. template <typename T> void MyQueue<T>::Remove() 
  21.      data.erase(data.begin( ) + 0,data.begin( ) + 1); 
  22.  
  23. template <typename T> void MyQueue<T>::Print() 
  24.      std::vector <int>::iterator It1; 
  25.      It1 = data.begin(); 
  26.      for ( It1 = data.begin( ) ; It1 != data.end( ) ; It1++ ) 
  27.         cout << " " << *It1<<endl; 
  28.  
  29. //Usage for C++ class templates 
  30. void main() 
  31.      MyQueue<int> q; 
  32.      q.Add(1); 
  33.      q.Add(2); 
  34.  
  35.      cout<<"Before removing data"<<endl; 
  36.      q.Print(); 
  37.  
  38.      q.Remove(); 
  39.      cout<<"After removing data"<<endl; 
  40.      q.Print();