// File: bsmain2.C // // Testing the BString class. #include #include #include #include #include "bstring.h" main() { int i, len ; BString str1("Hello "), str2("World") ; BString str3 = str1 + str2 ; cout << str3 << "\n" << endl ; len = str3.length() ; for (i = 0 ; i < len ; i++) { cout << "str3[" << setw(2) << i << "] = " << str3[i] << endl ; } cout << "\n" ; if (str1 < str2) { cout << "str1 < str2" << endl ; } else { cout << "str1 >= str2" << endl ; } cout << "\n" ; if (strcmp(str3,"Hello World") == 0) { // !memory leak! cout << "yes! auto convert!" << endl ; } else { cout << ":-(" << endl ; } cout << "\n" ; str3.chop(4) ; cout << str3 << endl ; }