string::string(const char* str)
{
if (str == NULL)
{
m_data = new char[1];
m_data[0] = '\0';
}
else
{
m_data = new char[strlen(str) +1];
strcpy(m_data, str);
}
}
string::string(const string &another)
{
m_data = new char[strlen(another.m_data) +1];
strcpy(m_data, another.m_data);
}
string&string::operator=(const string &rhs)
{
if (this == &rhs)
{
return *this;
}
delete []m_data;
m_data = new char[strlen(rhs.m_data)+1];
strcpy(m_data, rhs.m_data);
return *this;
}
{
if (str == NULL)
{
m_data = new char[1];
m_data[0] = '\0';
}
else
{
m_data = new char[strlen(str) +1];
strcpy(m_data, str);
}
}
string::string(const string &another)
{
m_data = new char[strlen(another.m_data) +1];
strcpy(m_data, another.m_data);
}
string&string::operator=(const string &rhs)
{
if (this == &rhs)
{
return *this;
}
delete []m_data;
m_data = new char[strlen(rhs.m_data)+1];
strcpy(m_data, rhs.m_data);
return *this;
}