当前位置: 首页 > news >正文

留言网站建设的报告就要外贸人才网论坛

留言网站建设的报告,就要外贸人才网论坛,百度知道在线问答,如何防止网站被攻击【C模拟实现】list的模拟实现 目录 【C模拟实现】list的模拟实现list模拟实现的部分代码list模拟实现中的要点const_iterator的实现push_backoperator运算符重载iterator begin()函数 作者#xff1a;爱写代码的刚子 时间#xff1a;2023.9.3 前言#xff1a;本篇博客关于li…【C模拟实现】list的模拟实现 目录 【C模拟实现】list的模拟实现list模拟实现的部分代码list模拟实现中的要点const_iterator的实现push_backoperator运算符重载iterator begin()函数 作者爱写代码的刚子 时间2023.9.3 前言本篇博客关于list的模拟实现和模拟实现中遇到的问题 list模拟实现的部分代码 namespace test {templateclass Tstruct list_node//默认公有{list_nodeT* _next;list_nodeT* _prev;T _val;list_node(const T val T()):_next(nullptr),_prev(nullptr),_val(val){}};templateclass T,class Ref,class Ptrstruct __list_iterator{typedef list_nodeT Node;typedef __list_iteratorT, Ref, Ptr Self;Node* _node;__list_iterator(Node* nodenullptr):_node(node){}__list_iterator(const Selfl):_node(l._node){}Ref operator*(){return _node-_val;}Ptr operator-(){return _node-_val;}Self operator(){_node_node-_next;return *this;}Self operator(int){Self tmp(_node);return tmp;}Self operator--() {_node_node-_prev;return *this;}Self operator--(int) {Self tmp(*this);_node_node-_prev;return *this;}bool operator!(const Self it) const//引用时一定要注意是否要加上const防止权限放大这里需要加上{return _node!it._node;}bool operator(const Self it) const{return _nodeit._node;}};templateclass Tclass list{typedef list_nodeT Node;public:typedef __list_iteratorT, T ,T* iterator;typedef __list_iteratorT, const T ,const T* const_iterator;iterator begin(){//return _head-_next;return iterator(_head-_next);}iterator end(){//return _head;return iterator(_head);}list(){_headnew Node;_head-_prev_head;_head-_next_head;}~list(){clear();delete _head;_headnullptr;}void clear(){iterator it begin();while(it!end()){iterase(it);}}void push_back(const T x){insert(end(),x);//注意这里是end(),不是end()-1;}void pop_back(){erase(--end());}iterator insert(iterator pos, const T x){Node*newnode new Node(x);pos._node-_prev-_nextnewnode;newnode-_prevpos._node-_prev;newnode-_nextpos._node;pos._node-_prevnewnode;return newnode;}iterator erase(iterator pos){Node*tmppos._node;Node*nexttmp-_next;tmp-_prev-_nexttmp-_next;tmp-_next-_prevtmp-_prev;delete tmp;tmp nullptr;return next;}private:Node* _head;}; } list模拟实现中的要点 const_iterator的实现 我们选择使用模版参数复用iterator的类设置三个模版参数templateclass T,class Ref,class Ptr并且typedef __list_iteratorT, const T ,const T* const_iterator,具体看代码的实现 push_back push_back函数中复用了insert函数但是注意的是传入的参数是end(),并不和pop_back函数中一样传入–end(); operator运算符重载 由于迭代器的实现类使用了模版参数所以有两种类const_iterator和iterator所以在使用引用作为传入参数时需注意引用要加const防止使用const_iterator类时权限放大 iterator begin()函数 在此函数中可以使用return _head-_next;编译器会自动使用构造函数构造iterator类 附类的拷贝构造一定要使用引用并考虑是否再加上const。
http://www.pierceye.com/news/845370/

相关文章:

  • 南宁网站快速排名提升一起来做网站17
  • 网站做数据分析什么软件是做网站的
  • 邯郸移动网站建设建设网站的报价
  • 做网站优化期间能收到网站吗科技创新与应用
  • 有没有做的很炫的科技型网站wordpress企业主题二次开发下载
  • 陕西住房和建设部网站深圳外贸建站模版
  • 自己做网站的各种代码wordpress只能访问主页
  • 四川监理协会建设网站长沙有哪些楼盘
  • 网站首页欣赏网站模板 wordpress带会员系统
  • 关于音乐的个人网站wordpress 报名表单
  • 国内做的好看的网站设计wordpress 与现有sso
  • 通辽网站建设罗湖中心区做网站
  • 宁波网站建设哪家快湛江专业的建站托管
  • 四川省城乡住房建设部网站首页自建wordpress 客户端
  • 番禺做网站价格百度app打开
  • 扬中网站推广导流非国产手机浏览器
  • 外国网站英语要求建立网站就是制作网页
  • 电商网站建设与运营实训可以做网站的app
  • 深圳南山区网站建设公司站长工具seo综合查询 分析
  • 互粉的网站是怎么做的网站建设公司利润怎么样
  • 个人网站平台搭建咸阳企业做网站
  • 租用外国服务器网站网站建设电子商务论文选题方向
  • 网站建设那种语言好wordpress 首页添加链接
  • NET开发网站开发工程师招聘潍坊市网站建设公司
  • 自己开发网站怎么盈利开发游戏需要多少资金
  • 先域名 还是先做网站塘厦
  • 企业公众号以及网站建设wordpress 代码块样式
  • 网站源码搭建教程大同建设银行保安招聘网站
  • 无锡网站设wordpress营销模板
  • 建站哪个好一点wordpress直达按钮