欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
數據結構五:字符串String(C++代碼)

 

數據結構系列均是本人個(gè)人搜集和寫(xiě)出來(lái)的,若有錯誤請大家批評指正。(有的是c++,有的是偽代碼)

 

1. String

class String

{

public:

       String( const char * str = NULL );

       String( const String & other);

       ~String();

       String & operator=( const String & other);

private:

       char * m_p;

};

 

String::String( const char * str )

{

       if ( NULL == str )

       {

              m_p = new char[1];

              if ( NULL != m_p )

              {

                     *m_p = '\0';

              }

       }

       else

       {

              m_p = new char[strlen(str)+1];

              if ( NULL != m_p )

              {

                     strcpy( m_p, str );

              }

       }

}

 

String::String( const String & other )

{

       m_p = new char[strlen(other.m_p)+1];

       if ( NULL != m_p )

       {

              strcpy( m_p, other.m_p );

       }

}

 

String & String::operator=( const String & other )

{

       if ( this != &other )

       {

              delete [] m_p;

              m_p = new char[strlen(other.m_p)+1];

              if ( NULL != m_p )

              {

                     strcpy( m_p, other.m_p );

              }

       }

       return *this;

}

 

String::~String()

{

       delete [] m_p;

}

 

 

 

本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
常見(jiàn)筆試/面試題目(一)
C語(yǔ)言經(jīng)典面試題
C++ Primer 第三章補充String類(lèi)的實(shí)現
C/C 程序設計員應聘常見(jiàn)面試試題 strcpy
String 類(lèi)的實(shí)現
經(jīng)典C/C++算法
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久