CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2004
    Location
    In the back seat of New Horizons.
    Posts
    1,238

    An iterator has turned implicitly into a typename...

    I'm using gcc. Ok, in file graph.cpp, on line 56 I got the below warnings...
    Code:
    g++ -g -c graph.cpp
    graph.cpp: In member function `bool
       graph<T>::search_list(std::basic_string<char, std::char_traits<char>,
       std::allocator<char> >)':
    graph.cpp:56: warning: `std::list<graph<T>::graph_node,
       std::allocator<graph<T>::graph_node> >::iterator' is implicitly a typename
    graph.cpp:56: warning: implicit typename is deprecated, please see the
       documentation for details
    g++ main.o graph.o -o main
    Why am I getting these warnings? All I did was make an iterator and from a list.
    Attached Files Attached Files
    Here are the rules, you must obey them or the gender bender will get you.

    And if you ever think of posting without code-tags, the evil monkey will come after you.

  2. #2
    Join Date
    Feb 2003
    Posts
    377

    Re: An iterator has turned implicitly into a typename...

    You're using it inside a template function, try:
    Code:
    for(typename list<graph_node>::iterator iter ...

  3. #3
    Join Date
    Apr 2004
    Location
    In the back seat of New Horizons.
    Posts
    1,238

    Re: An iterator has turned implicitly into a typename...

    Quote Originally Posted by jlou
    You're using it inside a template function, try:
    Code:
    for(typename list<graph_node>::iterator iter ...
    Thanks, that helped.

    The thing is that I've realized that I now don't need templates in this class, so I made some modifications to the program and these are the errors that I'm getting.
    Code:
    g++ -g -c graph.cpp
    graph.cpp: In member function `int graph::insert(std::basic_string<char,
       std::char_traits<char>, std::allocator<char> >)':
    graph.cpp:31: error: no matching function for call to `std::basic_string<char,
       std::char_traits<char>, std::allocator<char> >::copy(std::string&)'
    /usr/include/c++/3.3/bits/basic_string.tcc:772: error: candidates are: typename
       _Alloc::size_type std::basic_string<_CharT, _Traits, _Alloc>::copy(_CharT*,
       typename _Alloc::size_type, typename _Alloc::size_type) const [with _CharT =
       char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
    graph.cpp: At global scope:
    graph.cpp:73: error: `graph_node' was not declared in this scope
    graph.cpp:73: error: template argument 1 is invalid
    graph.cpp:73: error: template argument 2 is invalid
    graph.cpp:73: error: syntax error before `::' token
    make: *** [graph.o] Error 1
    Attached Files Attached Files
    Here are the rules, you must obey them or the gender bender will get you.

    And if you ever think of posting without code-tags, the evil monkey will come after you.

  4. #4
    Join Date
    Feb 2005
    Location
    Normandy in France
    Posts
    4,590

    Re: An iterator has turned implicitly into a typename...

    Corrections:
    graph.cpp, line 31:
    replace
    Code:
    (new_node.name).copy(name);
    with:
    Code:
    (new_node.name).assign(name);
    graph.cpp, line 73:
    replace
    Code:
    list<graph_node>::iterator graph::search_list_node(string name)
    With:
    Code:
    list<graph::graph_node>::iterator graph::search_list_node(string name)
    Note that your graph_node structure is recursive, and will not compile with Borland C++ 5.5.1, because std::list needs a complete type.
    Instead, a pointer or reference to std::list will work.
    "inherit to be reused by code that uses the base class, not to reuse base class code", Sutter and Alexandrescu, C++ Coding Standards.
    Club of lovers of the C++ typecasts cute syntax: Only recorded member.

    Out of memory happens! Handle it properly!
    Say no to g_new()!

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