当前位置:七七学习网文档大全求职指南求职笔试面试笔试题目创维数字笔试题精华» 正文

创维数字笔试题精华

[10-10 21:23:13]   来源:http://www.77xue.com  笔试题目   阅读:8174
概要:{delete [] m_data; // 由于m_data是内部数据类型,也可以写成 delete m_data;}// string的普通构造函数string::string(const char *str) // 6分{if(str==null){m_data = new char[1]; // 若能加 null 判断则更好*m_data = ‘\0’;} www.77xue.com哦 else{int length = strlen(str);m_data = new char[length+1]; // 若能加 null 判断则更好 strcpy(m_data, str);}}// 拷贝构造函数string::string(const string other) // 3分{int length = strlen(other.m_data);m_data = new char[length+1]; // 若能加 null 判断则更好st
创维数字笔试题精华,标签:驾照笔试题目,腾讯笔试题目,http://www.77xue.com
  {

  delete [] m_data;  

  // 由于m_data是内部数据类型,也可以写成 delete m_data;

  }

  // string的普通构造函数

  string::string(const char *str) // 6分

  {

  if(str==null)

  {

  m_data = new char[1]; // 若能加 null 判断则更好

  *m_data = ‘\0’;

  }
 

www.77xue.com哦
  else

  {

  int length = strlen(str);

  m_data = new char[length+1]; // 若能加 null 判断则更好

    strcpy(m_data, str);

  }

  }

  // 拷贝构造函数

  string::string(const string other) // 3分

  {

  int length = strlen(other.m_data);

  m_data = new char[length+1]; // 若能加 null 判断则更好

  strcpy(m_data, other.m_data);

  }

  // 赋值函数

  string string:perate =(const string &other) // 13分

  {

  // (1) 检查自赋值 // 4分

  if(this == other)

  return *this;

  // (2) 释放原有的内存资源 // 3分

  delete [] m_data;

  // (3)分配新的内存资源,并复制内容 // 3分

  int length = strlen(other.m_data);

  m_data = new char[length+1]; // 若能加 null 判断则更好

  strcpy(m_data,

  other.m_data);

  // (4)返回本对象的引用 // 3分

  return *this;

  }

上一页  [1] [2] [3] 


Tag:笔试题目驾照笔试题目,腾讯笔试题目求职指南 - 求职笔试面试 - 笔试题目

《创维数字笔试题精华》相关文章

联系我们 | 网站地图 | 范文大全 | 管理知识 | 教学教育 | 作文大全 | 语句好词
Copyright http://www.77xue.com--(七七学习网) All Right Reserved.
1 2 3 4 5 6 7 8 9 10