???????????????п?????????????String?????????????????????????????????????????Java?е?String??????????C++?????????????string???????????String??????????????????

????1???????????????????????????????????????????????????????????????????????????????????

????2???????????C++????????????????????????????????????????????????????????

????3??Java??String???????÷?????????о???????????????????

??????????????????????????????????????У???????????к?????????????????????????????String?????о???????????????????????????????????????????????????????ó????????????????????????????????????????????

????????????????????getName()??????Ч?????????????????μ?String??????Ч??????STL?е?string???????????????????????ж????????????????????????????getName()???????????????????????????????????????????????????????????????????????????????????????????????????????????????·?????????????????????

????????????????????????????ò????μ?String?????????C++?б???????????????????----???ü????????????????????????????String??????????????????????????????

class String
 {
 public:
     String();
     String(const String& other);
     String(const char* otherText);
     ... ... //??????????????????????????????
     ~String();
 
 public:
     const String& operator= (const String& other);
     const String& operator= (const char* otherText);
     const String& operator= (const char otherChar);
     ... ... //??????????????????????????????
 
 
 public:
     void append(const char* otherText??int count = -1);
     bool isEmpty() const;
     size_t length() const;
     ... ... //??????з?????????????????
   
   
 private:
     class InnerRefCountedString : public RefCountedBase
     {
     public:
         InnerRefCountedString(const size_t count)
             //(count+2)???????count?1????????????_containSize?0
             :_containSize(calculateContainSize(count))??_count(count) {
             _text = new char[_containSize + 1];
             assert(_text);
         }
 
         virtual ~InnerRefCountedString() {
             delete [] _text;
         }
 
         void copyData(const char* otherText?? const size_t count)  {
             assert(0 != otherText && count <= _containSize);
             memcpy(_text??otherText??count);
             _count = count;
             _text[_count] = 0;
         }
 
         void appendData(const char* appendText?? const size_t appendCount) {
             assert(0 != appendText && appendCount + _count <= _containSize);
             memcpy(_text + _count??appendText??appendCount);
             _count += appendCount;
             _text[_count] = 0;
         }
 
         char* getText () const {
             return _text;
         }
       
         static size_t calculateContainSize(const size_t s) {
             return ((s + 2) >> 1) * 3;
         }
         ... ... //???????????????????
     private:
         size_t    _containSize;
         size_t    _count;
         char*    _text;
     };
 
 private:
     typedef RefCountedPtr<InnerRefCountedString> SmartString;
     SmartString    _smartText;    //?й??????????????
 };