计算机经典笔试题
[10-10 21:21:19] 来源:http://www.77xue.com 笔试题目 阅读:8802次
概要: } 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) 释放
计算机经典笔试题,标签:驾照笔试题目,腾讯笔试题目,http://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] [4] [5] [6] [7]
Tag:笔试题目,驾照笔试题目,腾讯笔试题目,求职指南 - 求职笔试面试 - 笔试题目
- 上一篇:渤海银行笔试试题与备考经历