CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2001
    Posts
    81

    iterator for a list of template objects

    Hi,

    I have a compilation probleme when I create my iterator for a stl list of template object. This is the situation

    template <typename T>
    class A
    {
    ...
    };

    template <typename T >
    class B
    {
    ....
    private :
    std::list<A<T> >m_MyList;
    std::list<A<T> >::iterator m_MyIter;
    };

    Compiler give me this warning :
    warning C4346: 'std::list<A<T> >::iterator' : dependent name is not a type

    I have also this error when I use m_MyIter
    error C2146: syntax error : missing ';' before identifier 'm_MyIter'

    What is the best way to correct ths problem Thank you


    }

  2. #2
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: iterator for a list of template objects

    Quote Originally Posted by Geof
    What is the best way to correct ths problem
    To declare that the dependent name is indeed a type:
    Code:
    typename std::list<A<T> >::iterator m_MyIter;
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  3. #3
    Join Date
    Aug 2001
    Posts
    81

    Re: iterator for a list of template objects

    Wow it is not a fast awnser, it a ultra fast awnser. Thank you it solves my problem

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured