[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

C++ header for 'push_back'



I'm posting this here because I suspect my question may concern the c++ setup
on this Debian 2.0 install I have here. I'm trying to compile a sample snippet
of code (from the STL docs at SGI) and I can't find the right header to
declare push_back:

//--------------------my headers ----------------------
#include <algorithm> // needed for 'reverse' (is this correct?)
#include <iomanip>
#include <string>

//------------------- here's the code snippet ---------------
int main() { 
  string s(10u, ' ');           // Create a string of ten blanks.

  const char* A = "this is a test";
  s += A;
  cout << "s = " << (s + '\n');
  cout << "As a null-terminated sequence: " << s.c_str() << endl;
  cout << "The sixteenth character is " << s[15] << endl;
  
  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>

with line 17 being the s.push_back call.

I'm using the egcs setup that came with the default install of 2.0. I upgraded
some deb packages, so this is what I have now:

 egcc            2.90.29-0.6    The GNU (egcs) C compiler.
 libstdc++2.8    2.90.29-0.6    The GNU stdc++ library (egcs version)
 libstdc++2.8-de 2.90.29-0.6    The GNU stdc++ library (development files)


Any clues, anyone, that might help this c++ neophyte gain some ground here?

TIA for any light shed on these wonderful mysteries!


--
Bob Bernstein
at
Esmond, R.I., USA    <bernie@brainiac.com>  http://www.brainiac.com/bernie


Reply to: