002
16.07.2006, 18:27 Uhr
~vani
Gast
|
Vielen Dank! Mit einem Operator< gehts jetzt... ich versuche auch gleichzeitig einen iterator auf die map anzuwenden:
Code: |
MyMap::const_iterator iter; for(iter = m.begin(); iter != m.end(); iter++) { std::cout << (*iter).first << std::endl; }
|
die fehlermeldungen sind wie folgt:
Code: |
error: no match for 'operator<<' in 'std::cout << (&iter)->std::_Rb_tree_iterator<_Val, _Ref, _Ptr>::operator* [with _Val = std::pair<const Cell_Coords, int>, _Ref = const std::pair<const Cell_Coords, int>&, _Ptr = const std::pair<const Cell_Coords, int>*]()->std::pair<const Cell_Coords, int>::first' /usr/include/c++/3.3/bits/ostream.tcc:63: error: candidates are: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>&(*)(std::basic_ostream<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>] /usr/include/c++/3.3/bits/ostream.tcc:74: error: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ios<_CharT, _Traits>&(*)(std::basic_ios<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>] /usr/include/c++/3.3/bits/ostream.tcc:86: error: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base&(*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits<char>] /usr/include/c++/3.3/bits/ostream.tcc:122: error: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char, _Traits = std::char_traits<char>] /usr/include/c++/3.3/bits/ostream.tcc:156: error: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>] /usr/include/c++/3.3/bits/ostream.tcc:98: error: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char, _Traits = std::char_traits<char>] /usr/include/c++/3.3/ostream:178: error: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char, _Traits = std::char_traits<char>] /usr/include/c++/3.3/ostream:189: error: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char, _Traits = std::char_traits<char>] /usr/include/c++/3.3/ostream:193: error: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char, _Traits = std::char_traits<char>] /usr/include/c++/3.3/ostream:204: error: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char, _Traits = std::char_traits<char>] /usr/include/c++/3.3/bits/ostream.tcc:181: error: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char, _Traits = std::char_traits<char>] /usr/include/c++/3.3/bits/ostream.tcc:216: error: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>] /usr/include/c++/3.3/bits/ostream.tcc:241: error: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char, _Traits = std::char_traits<char>] /usr/include/c++/3.3/ostream:219: error: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char, _Traits = std::char_traits<char>] /usr/include/c++/3.3/bits/ostream.tcc:265: error: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char, _Traits = std::char_traits<char>] /usr/include/c++/3.3/bits/ostream.tcc:289: error: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char, _Traits = std::char_traits<char>] /usr/include/c++/3.3/bits/ostream.tcc:313: error: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_streambuf<_CharT, _Traits>*) [with _CharT = char, _Trai
|
ich dachte das evtl. jetzt auch der operator << definiert werden muss...habe es so versucht z.B.:
Code: |
std::string operator<<(const MyStruct& rhs) const { return "(" + rhs.a + "," + rhs.b + ")"; }
|
Klappt wohl noch nicht so ganz.... mit dem rückgabewert gibts probleme natürlich....ich weiß an der stelle jetzt aber nimmer weiter.
wie kann man denn dafür dann den iterator laufen lassen?
Danke für Hilfe |