C++ examples for STL:string
Use string overloaded subscript operator to create lvalue
#include <iostream> #include <string> using namespace std; int main() //from w w w. j a v a2 s. c o m { string s1( "happy" ); string s2( " birthday" ); string s3; // Use string copy constructor string s4( s1 ); s1[ 0 ] = 'H'; s1[ 6 ] = 'B'; cout << "\ns1 after s1[0] = 'H' and s1[6] = 'B' is: " << s1 << "\n\n"; }