On Fri, 30 Oct 1998, Bob Bernstein wrote: > > reverse(s.begin(), s.end()); > s.push_back('\n'); > cout << s; > } > > The compile complains that: > > /home/bernie/cpp/stl.cpp: In function `int main()': > /home/bernie/cpp/stl.cpp:17: no matching function for call to > `basic_string<char,string_char_traits<char>,__default_alloc_template<true,0> >
I assume the rest of the error message says ::push_back(char)? All the methods for string are in the basic_string class declaration; if push_back() isn't there, there is no push_back() implementation for string. Conveniently C++ requires the entire class to be declared in one place, so it's easy to see if a method exists. Stroustrup (page 593, 3rd edition) says string does not have push_back(). Try: s += '\n'; instead. You can see the basic_string class in /usr/include/g++/std/bastring.h; string is a typedef (typedef basic_string <char> string) which is in the <string> header. basic_string can also use wide characters (like Unicode, I guess), that's why it's a template. Havoc