#include using namespace std; class BString { friend ostream& operator<<(ostream& os, const BString& s); friend istream& operator>>(istream& is, BString& s); // this reads to white space friend istream& getline(istream& is, BString& s); // this reads up to newline friend istream& getline(istream& is, BString& s, char delim); // this reads up to delim friend BString operator+ (const BString& x, const BString& y); friend bool operator< (const BString& x, const BString& y); friend bool operator> (const BString& x, const BString& y); friend bool operator<=(const BString& x, const BString& y); friend bool operator>=(const BString& x, const BString& y); friend bool operator==(const BString& x, const BString& y); friend bool operator!=(const BString& x, const BString& y); public: BString(); // default constructor -- init to empty string BString(const char* s); // conversion from c-string ~BString(); // destructor for cleanup // copy constructor and assignment operator for deep copy BString(const BString& s); BString& operator=(const BString& s); BString& operator+=(const BString& s); // concatenate s onto calling obj int GetSize() const; // retrieve the size of the string BString substring(int pos, int len); private: char * str; // the pointer to my dynamic string int size; // size of string -- allocation will be // size+1, so that we can store AS a c-string void Resize(int newsize); // resize the string to newsize };