上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 23 下一页
摘要: 函数原型:vector<T> v; //采用模板实现类实现,默认构造函数vector(v.begin(), v.end()); //将v[begin(), end())区间中的元素拷贝给本身。vector(n, elem); //构造函数将n个elem拷贝给本身。vector(const vecto 阅读全文
posted @ 2022-05-08 15:39 纸包鱼 阅读(653) 评论(0) 推荐(0)
摘要: 使用就像单端数组 不同于数组是固定的空间,而是动态扩展的,他的动态扩展不是链表那样在原来的基础上继续扩展的,而是会直接开辟新的更大的空间,然后拷贝后删除原空间。他是单边的,只有一个边进一个边出,像是队列,同时它的迭代器也是支持随机访问的 v.begin代表的是最开始的值,头上的值,v.end代表的是 阅读全文
posted @ 2022-05-08 15:28 纸包鱼 阅读(36) 评论(0) 推荐(0)
摘要: 功能描述:从字符串中获取想要的子串函数原型:string substr(int pos = 0, int n = npos) const; //返回由pos开始的n个字符组成的字符串 阅读全文
posted @ 2022-05-08 15:20 纸包鱼 阅读(29) 评论(0) 推荐(0)
摘要: 函数原型:string& insert(int pos, const char* s); //插入字符串string& insert(int pos, const string& str); //插入字符串string& insert(int pos, int n, char c); //在指定位置 阅读全文
posted @ 2022-05-08 14:42 纸包鱼 阅读(204) 评论(0) 推荐(0)
摘要: string中单个字符存取方式有两种 char& operator[](int n); //通过[]方式取字符char& at(int n); //通过at方法获取字符 这两个的效果一样,可以进行字符的读写,同时注意字符串可以通过.size()函数判断字符串的大小 阅读全文
posted @ 2022-05-08 14:39 纸包鱼 阅读(590) 评论(0) 推荐(0)
摘要: 比较方式:字符串比较是按字符的ASCII码进行对比= 返回 0> 返回 1< 返回 -1 函数原型:int compare(const string &s) const; //与字符串s比较int compare(const char *s) const; //与字符串s比较 比较的时候从前到后比较 阅读全文
posted @ 2022-05-08 14:34 纸包鱼 阅读(746) 评论(0) 推荐(0)
摘要: 功能描述:查找:查找指定字符串是否存在替换:在指定的位置替换字符串函数原型:int find(const string& str, int pos = 0) const; //查找str第一次出现位置,从pos开始查找int find(const char* s, int pos = 0) cons 阅读全文
posted @ 2022-05-08 14:25 纸包鱼 阅读(909) 评论(0) 推荐(0)
摘要: 主要用于在已有字符串之后追加 函数原型:string& operator+=(const char* str); //重载+=操作符string& operator+=(const char c); //重载+=操作符string& operator+=(const string& str); // 阅读全文
posted @ 2022-05-08 14:12 纸包鱼 阅读(1051) 评论(0) 推荐(0)
摘要: 赋值的函数原型:string& operator=(const char* s); //char*类型字符串 赋值给当前的字符串string& operator=(const string &s); //把字符串s赋给当前的字符串string& operator=(char c); //字符赋值给当 阅读全文
posted @ 2022-05-08 14:04 纸包鱼 阅读(636) 评论(0) 推荐(0)
摘要: c++的string本身本质上是一个类,类中管理一个c语言类型的char*指针 用类的好处就是其中有很多的封装,并且可以自动管理内存 构造函数原型:string(); //创建一个空的字符串 例如: string str; string(const char* s); //使用字符串s初始化stri 阅读全文
posted @ 2022-05-08 13:57 纸包鱼 阅读(358) 评论(0) 推荐(0)
上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 23 下一页