Re[2]: C++ header for 'push_back'
Havoc Pennington <rhpennin@midway.uchicago.edu> wrote:
> 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.
So I've concluded this afternoon! I took a snippet off one of the newsgroups
that demonstrated push_back for a *vector* of strings, and tried to get it to
work for an array (named "array" oddly enough) of strings; the error message
clued me in:
/home/bernie/cpp/vector2.cpp: In function `int main()':
/home/bernie/cpp/vector2.cpp:30: request for member `push_back' in `array',
which is of non-aggregate type
`basic_string<char,string_char_traits<char>,__default_alloc_template<true,0>
> Stroustrup (page 593, 3rd edition) says string does not have push_back().
That's weird, my copy (same edition) says, "Because string has a
push_back()..." but in context it's clear that that must be a typo fixed in a
later printing. Mine is 5th printing, Jan, 1998. (?)
Now I wonder why that snip is in those STL docs? They are purported to be the
authoritative 'latest stuff', are they not? Oh well, there's a controversy for
another day.
Thanks!
--
Bob Bernstein
at
Esmond, R.I., USA <bernie@brainiac.com> http://www.brainiac.com/bernie
Reply to: