C/C++笔试题目大全
[10-10 21:21:19] 来源:http://www.77xue.com 笔试题目 阅读:8123次
概要: 4. { 5. head=p; 6. return p; 7. } 8. else 9. { 10. linka* tmp = reverse(p->next,head); 11. tmp->next = p; 12. return p; 13. } 14. } ②已知String类定义如下: class String {
C/C++笔试题目大全,标签:驾照笔试题目,腾讯笔试题目,http://www.77xue.com
4. {
5. head=p;
6. return p;
7. }
8. else
9. {
10. linka* tmp = reverse(p->next,head);
11. tmp->next = p;
12. return p;
13. }
14. }
②已知String类定义如下:
class String
{
public:
String(const char *str = NULL); // 通用构造函数
String(const String &another); // 拷贝构造函数
~ String(); // 析构函数
String & operater =(const String &rhs); // 赋值函数
private:
char *m_data; // 用于保存字符串
};
尝试写出类的成员函数实现。
答案:
String::String(const char *str)
{
if ( str == NULL ) //strlen在参数为NULL时会抛异常才会有这步判断
{
m_data = new char[1] ;
m_data[0] = '\0' ;
}
else
{
m_data = new char[strlen(str) + 1];
strcpy(m_data,str);
}
}
String::String(const String &another)
{
m_data = new char[strlen(another.m_data) + 1];
strcpy(m_data,other.m_data);
}
Tag:笔试题目,驾照笔试题目,腾讯笔试题目,求职指南 - 求职笔试面试 - 笔试题目
- 上一篇:广州日报
《C/C++笔试题目大全》相关文章
- C/C++笔试题目大全
- › 应聘职位名称 —— Accounting and Finance(会计与财务部分)
- › ACCOUNTANT(General)
- › An accounting position about financial
- › Resume accounts 会计行业英文简历应届生
- › 英文简历2--accounting-cl.doc
- › 英文简历(会计师)ACCOUNTANT(General)
- › 会计师英文简历ACCOUNTANT(General)
- › 专家写的英文简历模板ACCOUNTANT(General)
- › 会计人员英文简历Accounting Manager
- › 会计Accountant笔试题
- › cicc MRM 笔经
- › 埃森哲accenture笔试题型
- 在百度中搜索相关文章:C/C++笔试题目大全
- 在谷歌中搜索相关文章:C/C++笔试题目大全
- 在soso中搜索相关文章:C/C++笔试题目大全
- 在搜狗中搜索相关文章:C/C++笔试题目大全