// This illustrates gnu's own string type. It behaves // like all other decent string types. It is not, however, based // on the Draft Standard's version of strings, and I suppose it // will have to be changed when and if the Draft becomes a real standard. // The header String.h, where most of the String class is defined with // inlines, is in /usr/include/g++/. #include #include int main( void ) { // Two ways to initialize Strings. String s = "ABC"; String t("DEF"); // Printing strings using the << operator. cout << s << "XXX" << t << endl; // Concatenation and assignment. s = s + t; cout << s << endl; // Input from an input stream cout << "Type a string, please: "; cin >> s; cout << "And another: "; cin >> t; // Comparison works using >, <, >=, <=, ==, and !=. if( s > t ) cout << s << " comes after " << t << endl; else cout << s << " comes before " << t << endl; s = t; return(0); }