From 剑指Offer 何海涛 著
#include <iostream> #include <cstring> class CMyString { public: CMyString(char *pData = NULL); CMyString(const CMyString &other); ~CMyString(void); public: CMyString& operator=(const CMyString &other); private: char *m_pData; #if defined(NDEBUG) friend bool isEqual(const CMyString &left, const CMyString &right); #endif }; CMyString::CMyString(char *pData) { if(pData != NULL) { size_t len = strlen(pData); m_pData = new char[len+1]; strcpy(m_pData, pData); } else { m_pData = new char[1]; *m_pData = '