<<<Index>>>

The basic_string template

  • std::basic_string owns its own memory

  • Uses "position and count" system

  • STL provides

    typedef basic_string< char > string;
  • Construction:


#include <string>
using std::string;

// Variety of construction options:
string s1;              // empty
string s2 = s1;         // copy constructor
string s3 = "Hello";    // from C-string
string s4( "Hello", 4 );// first 4 chars
string s5( s3, 2, 5 );  // "llo"
string s6( 6, 'a' );    // "aaaaaa"

<<<Index>>>