#include<iostream>
//#include<string>
using namespace std; class Strings
{
public:
Strings(const char * str=NULL); Strings(const Strings &another);
~Strings();
Strings & operator=(const Strings &ths);
private:
char *m_data;
};
Strings::Strings(const char *str)
{
if(str==NULL)
{
m_data=new char[];
m_data[]='\0';
}
else
{
m_data=new char[strlen(str)+];
strcpy(m_data,str);
} }
Strings::Strings(const Strings &another)
{
m_data=new char[strlen(another.m_data)+];
strcpy(m_data,another.m_data );
}
Strings::~Strings()
{
delete [] m_data;
} Strings &Strings::operator=(const Strings &ths)
{
if(this==&ths)
return *this;
delete[]m_data;
m_data=new char[strlen(ths.m_data)+];
strcpy(m_data,ths.m_data);
return *this;
}
int main()
{
Strings a("abcdefg");
printf("%s\n",a);
Strings b(a);
printf("%s\n",b);
Strings c=b;
printf("%s\n",c);
system("pause");
return ; }

String 类的函数实现的更多相关文章

  1. string类find函数返回值判定

     string类find函数返回值判定 代码示例 #include<iostream> #include<cstring> using namespace std; int m ...

  2. C++string类常用函数

    C++string类常用函数 string类的构造函数:string(const char *s);    //用c字符串s初始化string(int n,char c);     //用n个字符c初 ...

  3. C++ string类及其函数的讲解

    文章来源于:http://www.cnblogs.com/hailexuexi/archive/2012/02/01/2334183.html C++中string是标准库中一种容器,相当于保存元素类 ...

  4. String 类的实现(3)String类常用函数

      2 #include<iostream> 3 #include<stdio.h> 4 #include<assert.h> 5 #include <iom ...

  5. 洛谷 P1308 统计单词数【string类及其函数应用/STL】

    题目描述 一般的文本编辑器都有查找单词的功能,该功能可以快速定位特定单词在文章中的位置,有的还能统计出特定单词在文章中出现的次数. 现在,请你编程实现这一功能,具体要求是:给定一个单词,请你输出它在给 ...

  6. 【Java】整理关于java的String类,equals函数和比较操作符的区别

    初学 Java 有段时间了,感觉似乎开始入了门,有了点儿感觉但是发现很多困惑和疑问而且均来自于最基础的知识折腾了一阵子又查了查书,终于对 String 这个特殊的对象有了点感悟大家先来看看一段奇怪的程 ...

  7. String 类 常用函数

    构造方法摘要: String(byte[] bytes)           通过使用平台的默认字符集解码指定的 byte 数组,构造一个新的 String. String(char[] value) ...

  8. 新手C#string类常用函数的学习2018.08.04

    ToLower()用于将字符串变为小写,注意字符串的不可变特性,需要重新赋值给另一个字符串变量. s = s.ToLower();//字符串具有不可变性,转换后需要重新赋值,不可仅有s.ToLower ...

  9. HDU——2093考试排名(string类及其函数的运用以及istringstream)

    考试排名 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submi ...

随机推荐

  1. 【shell脚本练习】grep sed awk

    下面是简单学习之后做得练习题,如果有不对的或者说解题思路不好的,请交流啊. Grep 练习 文件名grepfile Steve Blenheim:238-923-7366:95 Latham Lane ...

  2. Android Studio安装插件Genymotion

    Android Studio安装插件的方式其实和Eclipse大同小异.废话不多说,直接上图: 区域1:你当前已经安装了的插件 区域2:在线安装 区域3:从硬盘安装,即针对你已经下载好了的插件,可通过 ...

  3. UIEvent&nbsp;UIResponder&nbsp;UI_04

    1.事件(UIEvent),是由硬件设备捕捉到用户对设备的操作,把这个操作抽象成一个事件对象     ios中三大事件:触Touches摸晃动事件Motion,远程控制事件RemoteControl: ...

  4. (NO.00002)iOS游戏精灵战争雏形(二)

    在SpriteBuilder中新建Images文件夹,将所需要的图片素材全部拖入其中: 别忘了将其转换为智能精灵图表文件夹. 因为我们不需要为ipad和安卓设计,所以在项目设置里将所有出iphone以 ...

  5. Leetcode_111_Minimum Depth of Binary Tree

    本文是在学习中的总结,欢迎转载但请注明出处:http://blog.csdn.net/pistolove/article/details/41964249 Minimum Depth of Binar ...

  6. 字符转码开源库libiconv目前还不支持64位

    最新版的libiconv 1.14目前还不支持64位系统,只能编译出32位库. libiconv 1.14下载地址: http://ftp.gnu.org/pub/gnu/libiconv/libic ...

  7. 【一天一道LeetCode】#28. Implement strStr()

    一天一道LeetCode系列 (一)题目 Implement strStr(). Returns the index of the first occurrence of needle in hays ...

  8. SQLServer 基础

    1当设计表时,对表进行结构性的修改(如将原来可以null的改为不可null),直接改则不允许保存修改,需要选择 工具----选项----designers—表设计器和数据库设计器---阻止保持要求重新 ...

  9. 谈谈java中的线程(初级概念)

    定义 关于进程与线程的定义 可参看一下这个介绍 http://www.ruanyifeng.com/blog/2013/04/processes_and_threads.html 在不细抠定义的情况下 ...

  10. Oracle E-Business Suite Maintenance Guide Release 12.2(Patching Utilities)

    更多内容参考: http://docs.oracle.com/cd/E51111_01/current/acrobat/122ebsmt.zip Oracle Patch Application As ...