- Assignment/Copying
string s1 = "Hello": string s2; s2 = s1; // s2 gets a copy of s1. - Comparison
string s1 = "Hello"; string s2 = "World"; if ( s1 < s2 ) { cout << s1 " comes before " << s2 << endl; } - Concatenation
string s1 = "Hello"; string s2 = "World!"; string s; s = s1 + ", " + s2; cout << s << endl; Output: Hello, World! - Searching
- find
int pos; string s = "Hello, World!"; pos = s.find("World"); // pos = 7 pos = s.find(','); // pos = 5 pos = s.find("Cat"); // pos is = string::npos
- find