CString str = "Hello World!"; int size = str.GetLength(); cout << "Size of the string is: " << size << endl;
CString str1 = "Hello"; CString str2 = "World"; int size = str1.GetLength() + str2.GetLength(); cout << "Size of the concatenated string is: " << size << endl;In this example, we create two CString objects 'str1' and 'str2' and initialize them with the strings "Hello" and "World" respectively. Then we concatenate the two strings and calculate the size of the resulting string by adding the length of the two original strings. Finally, we print the size of the concatenated string using cout. Package/library: Microsoft Foundation Classes (MFC) library.