Class std::string can be initialized in five forms: by a C-string, by part of a C-string, by another string object, by a sequence of characters, or by part of another string object. For example:
#include using namespace std;void f(){ const char text[] = "hello world"; string s1 = text; // initialization of string object with a C-style string string s2(s1); // initialize with another string object string s3(&text[0], &text[5]); // initialize by part of a C-string string s4(10, 0); // by a sequence of 10 characters string s5 ( s2.begin(), s2.find(' ')); // by part of another string object; s5 = "hello"}