#ifndef _MY_STRING_H_ #define _MY_STRING_H_ #include using namespace std; class String { public: String( const char *cString = "" ); // Constructor String( char ch ); // Constructor String( const String & str ); // Copy constructor ~String( ) // Destructor { delete [ ] buffer; } const String & operator= ( const String & rhs ); // Copy const String & operator+=( const String & rhs ); // Append const char *c_str( ) const // Return C-style String { return buffer; } int length( ) const // Return String length { return strLength; } char operator[]( int k ) const; // Accessor operator[] char & operator[]( int k ); // Mutator operator[] private: char *buffer; // storage for characters int strLength; // length of String (# of characters) int bufferLength; // capacity of buffer }; ostream & operator<<( ostream & out, const String & str ); // Output istream & operator>>( istream & in, String & str ); // Input istream & getline( istream & in, String & str ); // Read line istream & getline( istream & in, String & str, char delim ); // Read line String operator+( const String & lhs, const String & rhs ); // Concatenation bool operator==( const String & lhs, const String & rhs ); // Compare == bool operator!=( const String & lhs, const String & rhs ); // Compare != bool operator< ( const String & lhs, const String & rhs ); // Compare < bool operator<=( const String & lhs, const String & rhs ); // Compare <= bool operator> ( const String & lhs, const String & rhs ); // Compare > bool operator>=( const String & lhs, const String & rhs ); // Compare >= #endif