没有合适的资源?快使用搜索试试~ 我知道了~
c++string类函数原型借鉴.pdf
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 83 浏览量
2021-12-25
17:55:43
上传
评论
收藏 13KB PDF 举报
温馨提示
试读
8页
c++string类函数原型借鉴.pdf
资源推荐
资源详情
资源评论
#include<iostream>
#include<cstring>
using namespace std;
class String{
private:
char *pstr;
public:
String(const char *str=" ")
{
pstr=new char[strlen(str)+1];
strcpy(pstr,str);
}
String(const String&s){// 复制构造函数
pstr=new char[strlen(s.pstr)+1];
strcpy(pstr,s.pstr);
}
void show(){
cout<<pstr<<endl;
}
friend ostream&operator<<(ostream &os,String&s);// 重 载 输 出 运 算 符 <<
1
friend istream&operator>>(istream &is,String&s);
String &operator=(String &s);// 重 载 赋 值 运 算 符
3
int length(){return strlen(pstr);}// 获 取 字 符 串 的 长 度
4
String &operator+(String &s);// 重载 +运算符连接
String &operator+=(const String &s);// 把字符串 s 连接到当前字符串的结尾
char &operator[](int n);
bool isempty(){return length()==0?true:false;}; // 当前字符串是否为空
friend bool operator==(const String &s1,const String &s2);// 比较两个字符串是否相等
bool operator>(const String&s);
bool operator<(const String&s);
bool operator>=(const String&s);
bool operator<=(const String&s);
bool operator!=(const String&s);
String &Toupper();// 将小写化为大写
String &Tolpper();// 大写变小写
int find_first_of(char c);// 从前向后查找 c 出现的第一个位置
int find_last_of(char c);// 从后向前查找 c 出现的第一个位置
int find_s_first_of(const char *s);// 从前向后查找字符串 s 第一次出现的位置
int find_s_last_of(const char *s);// 从后向前查找字符串 s 第一次出现的位置
int find(char s,int pos);// 从 pos 开始查找字符 c 在字符串中的位置
资源评论
gw19501103285
- 粉丝: 1
- 资源: 7万+
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 通道处理过程的模拟通常涉及对通道处理机制的理解与实现.txt
- Flume进阶-自定义拦截器jar包
- Dubins曲线算法讲解和在运动规划中的使用.pdf
- 上市公司-股票性质数据-工具变量(民企、国企、央企)2003-2022年.dta
- 上市公司-股票性质数据-工具变量(民企、国企、央企)2003-2022年.xlsx
- Reeds+Shepp曲线算法讲解和实现.pdf
- 毕业设计基于SpringBoot+MyBatisPlus+MySQL+Vue的外卖配送信息系统源代码+数据库
- 词向量(Word Embeddings)是自然语言处理(NLP)领域的一种重要技术.txt
- Surfer,线性函数
- MyBatis 的动态 SQL 是其核心特性之一.txt
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功