编写类String的构造函数,析构函数和赋值函数
来源:互联网 发布:上海灵娱网络怎么样 编辑:程序博客网 时间:2024/05/21 13:56
已知类String的原型
class String
{
public:
String(const char *str = NULL);
String(const String &other);
~String(void);
String &operate = (const String &other);
private:
char *m_data;
}
String::~String(void)
{
delete [] m_data;
//由于m_data是内部数据类型,也可以写成delete m_data;
}
String::String(const char *str)
{
if (str == NULL)
{
m_data = new char[1];
*m_data = '/0';
}
else
{
int length = strlen(str);
m_data = new char[length + 1];
strcpy(m_data, str);
}
}
String::String(const String &other)
{
int length = strlen(other.m_data);
m_data = new char[length + 1];
strcpy(m_data, other.m_data);
}
String &String::operate = (const String &other)
{
}
- 编写类String的构造函数、拷贝构造函数、析构函数和赋值函数
- 编写类String 的构造函数、拷贝构造函数、析构函数和赋值函数
- 网易游戏笔试题:编写string类的构造函数、拷贝构造函数、赋值构造函数和析构函数
- 编写类String的构造函数、析构函数和赋值函数
- 编写类String的构造函数,析构函数和赋值函数
- 编写类String的构造函数、析构函数和赋值函数
- 编写类String的构造函数、析构函数和赋值函数
- 编写类String 的构造函数、析构函数和赋值函数
- 编写类String的构造函数、析构函数和赋值函数
- 如何正确编写类String的构造函数、析构函数和赋值函数
- 编写类String的构造函数、析构函数和赋值函数
- 编写类String的构造函数、析构函数和赋值函数
- 编写类String的构造函数、析构函数和赋值函数
- 编写类String的构造函数、析构函数和赋值函数
- 编写类String 的构造函数、析构函数和赋值函数
- 编写类String的构造函数、析构函数和赋值函数
- 编写类String的构造函数、析构函数和赋值函数
- 编写类String的构造函数、析构函数和赋值函数
- 使用java发送email
- 程序员的七种武器
- jquery使用方法简介
- sap视频教程
- spring + ibatis jpetstore 摘要
- 编写类String的构造函数,析构函数和赋值函数
- 关于对象的offsetWidht和offsetHeight
- vb6 GUid 生成
- Apache Tomcat 5.5 Servlet/JSP 容器安装 TOMCAT
- 中国地震带的分布
- 在spring2.5中无法使用dwr2
- 猴子摘桃程序
- 表格里的斜线,类似课程表的斜线
- 表格里的斜线,类似课程表的斜线