1。
const char* p1;
与
char* const p2;
有什么区别
chinaren(251665710) 12:58:15
p1可以修改
p2不可以修改
2。函数付值的实现(not 传值)
class chinaren
{
public:
chinaren(){m_pData=NULL;};
virtual ~chinaren()
{
if(m_pData)
delete []m_pData;
m_pData = NULL;
};
chinaren& operator=(chinaren& right)
{
if(this == &right)
return *this;
delete []m_pData;
int iCount = strlen(right.m_pData);
m_pData = new char[iCount + 1];
if(m_pData == NULL)
return *this;
memset(m_pData, 0, iCount+1);
strncpy(m_pData, right.m_pData, iCount);
return *this;
};
private:
char *m_pData;
};
感谢郭大海与群里的其他朋友参与
阅读(659) | 评论(1) | 转发(0) |