#include #include int main() { CString string1 = "Hello World!"; // initialize with a string literal CString string2 = string1; // initialize with a string object CString string3, string4("This is a test"); CString message1 = "\n---- Test of object initializations ----\n"; CString message2 = "\n---- Test of string assignment ----\n"; CString message3= "\n---- Test of string concatenation ----\n"; CString message4 = "\n---- Test of string comparison ----\n"; cout << message1; cout << " string1, which was initialized by a string literal,\n" << " has the value: " << string1 << endl; cout << " string2, which was initialized by a string object,\n" << " has the value: " << string2 << endl; cout << " The string lengths of string1 through string4 are: " << string1.GetLength() << ", " << string2.GetLength() << ", " << string3.GetLength() << ", and " << string4.GetLength() << endl; cout << message2; string3 = string4; cout << " After assigning string4 to string3, string3 is now:\n " << string3 << endl; string4 = "of a string literal"; cout << " After assigning a string literal to string4, string4 is now:\n " << string4 << endl; cout << " The length of this string is: " << string4.GetLength() << endl; cout << message3; string3 = " " + string3 + " " + string4; cout << " After concatenation, string3 is now:\n" << string3 << endl; cout << message4; if (string1 == string2) cout << " string1 and string2 are equal" << endl; else cout << " string1 and string2 are not equal" << endl; if (string3 == string4) cout << " string3 and string4 are equal\n" << endl; else cout << " string3 and string4 are not equal\n" << endl; return 0; }