#include "mString.h"
mString::mString(const char* str /*= NULL*/)
{
if (str == NULL)
{
m_data = new char(1);
*m_data = '\0';
}
else
{
m_data = new char(strlen(str)+1);
strcpy(m_data,str);
}
}
mString::mString(const mString &other)
{
m_data = new char(strlen(other.m_data)+1);
strcpy(this->m_data,other.m_data);
}
mString::~mString(void)
{
delete m_data;
}
mString & mString::operator=(const mString &other)
{
if (this != &other )
{
int len = strlen(other.m_data);
delete m_data;
m_data = new char(len+1);
strcpy(m_data,other.m_data);
}
return *this;
}
void mString::mPrintf()
{
cout<<m_data<<endl;
}
mString
最新推荐文章于 2022-12-06 20:54:52 发布