C++
zhzhyyds
大家一起加油
展开
-
C++list简单底层实现代码
#pragma once #include"reverse_iterator.h" namespace zh { //list单个节点的类 template<class T> struct ListNode { ListNode<T>* _next; ListNode<T>* _prev; T _data; ListNode(const T& x = T()) :_data(x) , _next(nullptr) , _原创 2022-04-10 16:43:03 · 1187 阅读 · 0 评论 -
C++vector底层简单实现代码
#pragma once namespace zh { template<class T> class vector { public: typedef T* iterator; typedef const T* const_iterator; //构造 vector() :_start(nullptr), _finish(nullptr), _endofstorage(nullptr) {} //vector内部的swap函数,交原创 2022-03-22 18:00:52 · 782 阅读 · 0 评论 -
C++string的模拟实现
#pragma once #include<iostream> #include<assert.h> using namespace std; namespace zh { class string { public: void swap(string& s) { std::swap(_str, s._str); std::swap(_size, s._size); std::swap(_capacity, s._capacity);原创 2022-03-17 17:44:57 · 1098 阅读 · 0 评论