亚洲国产日韩欧美在线a乱码,国产精品路线1路线2路线,亚洲视频一区,精品国产自,www狠狠,国产情侣激情在线视频免费看,亚洲成年网站在线观看

大自然的諺語(yǔ)

時(shí)間:2025-08-24 13:57:22 秀雯 諺語(yǔ) 我要投稿

有關(guān)于大自然的諺語(yǔ)260句

  已知類(lèi)String的原型為:

有關(guān)于大自然的諺語(yǔ)260句

  class String

  {

  public:

  String(const char *str = NULL); /pic/p>

  String(const String &other); /pic/p>

  ~ String(void); /pic/p>

  String & operate =(const String &other); /pic/p>

  private:

  char *m_data; /pic/p>

  };

  請(qǐng)編寫(xiě)String的上述4個(gè)函數(shù)。

  標(biāo)準(zhǔn)答案:

  /pic/p>

  String::~String(void) /pic/p>

  {

  delete [] m_data;

  /pic/p>

  }

  /pic/p>

  String::String(const char *str) /pic/p>

  {

  if(str==NULL)

  {

  m_data = new char[1]; /pic/p>

  *m_data = ‘\0’;

  }

  else

  {

  int length = strlen(str);

  m_data = new char[length+1]; /pic/p>

  strcpy(m_data, str);

  }

  }

  /pic/p>

  String::String(const String &other) /pic/p>

  {

  int length = strlen(other.m_data);

  m_data = new char[length+1]; /pic/p>

  strcpy(m_data, other.m_data);

  }

  /pic/p>

  String & String::operate =(const String &other) /pic/p>

  {

  /pic/pic/p>

  if(this == &other)

  return *this;

  /pic/pic/p>

  delete [] m_data;

  /pic/pic/p>

  int length = strlen(other.m_data);

  m_data = new char[length+1]; /pic/p>

  strcpy(m_data, other.m_data);

  /pic/pic/p>

  return *this;

  }

【大自然的諺語(yǔ)】相關(guān)文章:

關(guān)于大自然的諺語(yǔ)12-31

大自然的英語(yǔ)諺語(yǔ)80句07-16

關(guān)于大自然的諺語(yǔ)320句12-12

關(guān)于大自然的諺語(yǔ)200句12-10

小學(xué)生關(guān)于認(rèn)識(shí)大自然的諺語(yǔ)190句12-26

立夏的諺語(yǔ)06-21

冬日的諺語(yǔ)09-20

植樹(shù)的諺語(yǔ)12-19

英語(yǔ)諺語(yǔ)08-26