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