Guys I have this simple code on templates
Qt Code:
  1. #include <iostream.h>
  2. #include <vector>
  3.  
  4. template <typename T>
  5. class MyQueue
  6. {
  7. std::vector<T> data;
  8. public:
  9. void Add(T const &);
  10. void Remove();
  11. void Print();
  12. };
  13.  
  14. template <typename T> void MyQueue<T> ::Add(T const &d)
  15. {
  16. data.push_back(d);
  17. }
  18.  
  19. template <typename T> void MyQueue<T>::Remove()
  20. {
  21. data.erase(data.begin( ) + 0,data.begin( ) + 1);
  22. }
  23.  
  24. template <typename T> void MyQueue<T>::Print()
  25. {
  26. std::vector <double>::iterator It1;
  27. It1 = data.begin();
  28. for ( It1 = data.begin( ) ; It1 != data.end( ) ; It1++ )
  29. cout << " " << *It1<<endl;
  30.  
  31. }
  32.  
  33.  
  34. int main (int argc,char *argv[])
  35. {
  36. MyQueue<double> q;
  37. q.Add(1.34);
  38. q.Add(2.24);
  39.  
  40. cout<<"Before removing data"<<endl;
  41. q.Print();
  42.  
  43. q.Remove();
  44. cout<<"After removing data"<<endl;
  45. q.Print();
  46. return 0;
  47. }
To copy to clipboard, switch view to plain text mode 
in my
template <typename T> void MyQueue<T>::Print()
method I want this iterator to be synchronize with my typename T
Qt Code:
  1. std::vector <double>::iterator It1;
To copy to clipboard, switch view to plain text mode 
meaning if i say
Qt Code:
  1. MyQueue<int> q;
To copy to clipboard, switch view to plain text mode 
the iterator should adjust himself to int, right now its always expecting a double.
Please help,
baray98