Click to See Complete Forum and Search --> : An iterator has turned implicitly into a typename...
YourSurrogateGod
October 8th, 2005, 07:54 PM
I'm using gcc. Ok, in file graph.cpp, on line 56 I got the below warnings...
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.
jlou
October 8th, 2005, 09:02 PM
You're using it inside a template function, try:for(typename list<graph_node>::iterator iter ...
YourSurrogateGod
October 8th, 2005, 09:23 PM
You're using it inside a template function, try: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.
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
SuperKoko
October 9th, 2005, 02:39 AM
Corrections:
graph.cpp, line 31:
replace
(new_node.name).copy(name);
with:
(new_node.name).assign(name);
graph.cpp, line 73:
replace
list<graph_node>::iterator graph::search_list_node(string name)
With:
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.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.