Hi Guys,
I am having issues with reading from a list made up of lists. I dont want to paste my code as it is for an assignment, but here is the basic setup.
i have a class person that has declared
list<char> name;
push to the list;
i have a class School that has declared
list<person> people;
push person to people from the other list;
So now the List name People should contain a single row of names.
when i try to print from the list People i get the following CRAZY error that i have no idea about. I can print from List name without a problem.
This is the code used for printing :
void printList()
{
list<person>::const_iterator itr;
for (itr = people.begin(); itr != people.end(); itr++ ) {
cout << *itr;
}
}
The error message is as follows in g++ compiler
maze5.cpp: In member function 'void School::printList()':
maze5.cpp:78: error: no match for 'operator<<' in 'std::cout << itr. std::_List_const_iterator<_Tp>::operator* [with _Tp = person]()'
/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../../../include/c++/4.0.2/bits/ostream.tcc:67: note: 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>]
/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../../../include/c++/4.0.2/bits/ostream.tcc:78: note: 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>]
/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../../../include/c++/4.0.2/bits/ostream.tcc:90: note: 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>]
/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../../../include/c++/4.0.2/bits/ostream.tcc:125: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char, _Traits = std::char_traits<char>]
/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../../../include/c++/4.0.2/bits/ostream.tcc:159: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../../../include/c++/4.0.2/bits/ostream.tcc:102: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char, _Traits = std::char_traits<char>]
/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../../../include/c++/4.0.2/ostream:176: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char, _Traits = std::char_traits<char>]
/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../../../include/c++/4.0.2/ostream:187: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../../../include/c++/4.0.2/ostream:191: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char, _Traits = std::char_traits<char>]
/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../../../include/c++/4.0.2/ostream:202: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../../../include/c++/4.0.2/bits/ostream.tcc:183: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char, _Traits = std::char_traits<char>]
/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../../../include/c++/4.0.2/bits/ostream.tcc:218: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../../../include/c++/4.0.2/bits/ostream.tcc:242: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char, _Traits = std::char_traits<char>]
/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../../../include/c++/4.0.2/ostream:217: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char, _Traits = std::char_traits<char>]
/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../../../include/c++/4.0.2/bits/ostream.tcc:265: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char, _Traits = std::char_traits<char>]
/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../../../include/c++/4.0.2/bits/ostream.tcc:288: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char, _Traits = std::char_traits<char>]
/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../../../include/c++/4.0.2/bits/ostream.tcc:311: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_streambuf<_CharT, _Traits>*) [with _CharT = char, _Traits = std::char_traits<char>]
/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../../../include/c++/4.0.2/ostream:447: note: std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, char) [with _CharT = char, _Traits = std::char_traits<char>]
/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../../../include/c++/4.0.2/bits/ostream.tcc:509: note: std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, char) [with _Traits = std::char_traits<char>]
/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../../../include/c++/4.0.2/ostream:458: note: std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, signed char) [with _Traits = std::char_traits<char>]
/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../../../include/c++/4.0.2/ostream:463: note: std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, unsigned char) [with _Traits = std::char_traits<char>]
/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../../../include/c++/4.0.2/bits/ostream.tcc:571: note: std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const char*) [with _CharT = char, _Traits = std::char_traits<char>]
/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../../../include/c++/4.0.2/bits/ostream.tcc:616: note: std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const char*) [with _Traits = std::char_traits<char>]
/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../../../include/c++/4.0.2/ostream:497: note: std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const signed char*) [with _Traits = std::char_traits<char>]
/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../../../include/c++/4.0.2/ostream:502: note: std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const unsigned char*) [with _Traits = std::char_traits<char>]