代码:
class AutoDeleteArPtr { public: explicit AutoDeleteArPtr(char* &cPtr) { m_cPtr=cPtr; } ~AutoDeleteArPtr() { if (NULL != m_cPtr) { delete[] m_cPtr; m_cPtr = NULL; } } private: AutoDeleteArPtr(const AutoDeleteArPtr& adap); AutoDeleteArPtr& operator=(const AutoDeleteArPtr& rhs); private: char* m_cPtr; }; |