#include <iostream>
#include 
<string>
using namespace std;

class myString
{
private:
    
char* m_date;

public:
    myString(
const char* str)
    
{
        
if(str == NULL)
        
{
            m_date 
= new char[1];
            
*m_date = '\0';
        }

        
else
        
{
            
int lenth = strlen(str);
            m_date 
= new char[lenth + 1];
            strcpy(m_date, str);
        }


    }


    myString(
const myString &other)
    
{
        
int lenth = strlen(other.m_date);
        m_date 
= new char[lenth + 1];
        strcpy(m_date, other.m_date);
    }


    myString 
& operator = (const myString &other)
    
{
        
if(*this == other)
            
return *this;
        delete []m_date;

        
int lenth = strlen(other.m_date);
        m_date 
= new char[lenth + 1];
        strcpy(m_date, other.m_date);
        
return *this;
    }


    
~myString()
    
{
        delete []m_date;
    }


}
posted on 2009-06-07 22:45  Jackill  阅读(330)  评论(0编辑  收藏  举报