Thread: Class templates and iterators

  1. #1
    Registered User
    Join Date
    Jun 2007
    Posts
    34

    Class templates and iterators

    Hey Everybody,
    I have this issue. I have a class template of type T such as template<typename T>. In one of the functions of the class, I can do this: vector<T> vec, but not vector<T>::iterator it, because it gives me an syntax errors. Could somebody please explain what is going on?

    Thank You

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    You have to add typename before the vector<T>::iterator so the compiler knows you are talking about a type.

  3. #3
    Registered User
    Join Date
    Jun 2007
    Posts
    34
    Thank You. It helped.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. <list> iterators with nested templates
    By dwylie in forum C++ Programming
    Replies: 4
    Last Post: 07-19-2005, 12:13 PM
  2. im extreamly new help
    By rigo305 in forum C++ Programming
    Replies: 27
    Last Post: 04-23-2004, 11:22 PM
  3. Templates and Inheritance problem
    By WebSnozz in forum C++ Programming
    Replies: 0
    Last Post: 04-11-2004, 02:39 PM
  4. Prime Number Generator... Help !?!!
    By Halo in forum C++ Programming
    Replies: 9
    Last Post: 10-20-2003, 07:26 PM
  5. include question
    By Wanted420 in forum C++ Programming
    Replies: 8
    Last Post: 10-17-2003, 03:49 AM