what is the best way to design a string class constructor? The following constructors definitely have problem: two pointers pointing one object, if one of them is destructed, the other will cause a fatal error. So, what is the best way to design a constructor for a string class?
class CMyString{ private: char *pData; public: CMyString(char *_p=NULL):pData(_p){ } CMyString(CMyString &_str):pData((_str.pData){ } }