STL
Pluto张同学
学生
展开
-
List的模拟实现
#pragma once #include<iostream> #include<assert.h> using namespace std; namespace zwh { //结点类 template<class T> struct __list_node { T _data; __list_node<T>* _next; __list_node<T>* _prev; __list_node(const T&原创 2021-05-11 16:49:23 · 153 阅读 · 0 评论 -
vector的模拟实现
vector的模拟实现(包括增删查改)如下 #include<iostream> #include<assert.h> using namespace std; #pragma once namespace zwh { template<class T> class vector { public: //跟string一样 vector中的迭代器也是原生指针 typedef T* iterator; iterator begin() { r原创 2021-05-06 13:48:59 · 98 阅读 · 2 评论 -
STL中的string
string类 string是表示字符串的字符串类 string类的常用接口说明 1.string类对象的常见构造 下面是三种常见的string类对象构造 void Teststring() { string s1;//构造一个空的string类对象s1 string s2("hello");//用C字符串风格来构造string类对象s4 string s3(s2);//拷贝构造s3 } 2.string类对象的容量操作 函数名称 功能说明 size 返回字符串原创 2021-05-05 14:31:35 · 3621 阅读 · 10 评论