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

福建建设人才市场网站WordPress与hexo的区别

福建建设人才市场网站,WordPress与hexo的区别,wordpress减少查询,做网页怎么做这是关于一个普通双非本科大一学生的C的学习记录贴 在此前#xff0c;我学了一点点C语言还有简单的数据结构#xff0c;如果有小伙伴想和我一起学习的#xff0c;可以私信我交流分享学习资料 那么开启正题 今天分享的是关于list的模拟实现#xff0c;今天只实现一部分基…这是关于一个普通双非本科大一学生的C的学习记录贴 在此前我学了一点点C语言还有简单的数据结构如果有小伙伴想和我一起学习的可以私信我交流分享学习资料 那么开启正题 今天分享的是关于list的模拟实现今天只实现一部分基础函数重点是const迭代器 1.iterator的访问 由于访问方式的不同iterator的类实现*的重载同时还应该实现-的重载 T operator*() {return _node-_data; }T* operator-() {return _node-_data; } 2.自定义类型相关 当list中存储的是自定义类型时我们来看下面的代码 struct Date {int _year;int _month;int _day;Date(int year 0,int month 1,int day 1):_year(year),_month(month),_day(day){} };void Test_list2() {listDate l;l.push_back(Date(2006,9,12));l.push_back(Date(1999,5,6));listDate::iterator it l.begin();while(it ! l.end()){cout it-_year - it-_month - it-_day endl;it;} } 很明显如果要通过it访问_year或_month_day应该是it--_year 第一次-通过it访问到Date第二次-通过Date再访问到_year 而我们要写出上面说的代码是不能编译通过的vs环境下而写一次-可以编译通过这是因为为了增强代码的可读性编译器在这里特殊处理了不需要我们写两次一次即可 3.const迭代器 实际运用中我们难免遇到const迭代器的存在 const迭代器是const对象的迭代器实际运用中我们不会自己创建const对象因为没有实际意义而在一些函数调用中难免出现const修饰的情况这个时候const迭代器的存在就不可或缺了 对于const与非const的存在我们需要对模板进行一些改造 typedef __list_iteratorT, T, T* iterator; typedef __list_iteratorT, const T, const T* const_iterator; 对应的有下面这些迭代器相关函数 iterator begin() {return iterator(_head-_next); }iterator end() {return iterator(_head); }const_iterator begin() const {return const_iterator(_head-next); }const_iterator end() const {return const_iterator(_head); } 下面是完整的代码以及测试代码 #includeiostream #includelistusing namespace std;namespace wkl {templateclass Tstruct __list_node{__list_node* _next;__list_node* _prev;T _data;__list_node(const T x T()):_next(nullptr),_prev(nullptr),_data(x){}};// T T T*templateclass T, class Ref, class Ptrstruct __list_iterator{typedef __list_nodeT Node;typedef __list_iteratorT, Ref, Ptr Self;Node* _node;__list_iterator(Node* node nullptr):_node(node){}Ref operator*(){return _node-_data;}Ptr operator-(){return _node-_data;}Self operator(){_node _node-_next;return *this;}Self operator(int){Self tmp(*this);_node _node-_next;return tmp;}Self operator--(){_node _node-_prev;return *this;}Self operator--(int){Self tmp(*this);_node _node-_prev;return tmp;}bool operator!(const Self it) const {return _node ! it._node;}bool operator(const Self it) const {return _node it._node;}templateclass Tclass list{typedef __list_nodeT Node;public:typedef __list_iteratorT, T, T* iterator;typedef __list_iteratorT, const T, const T* const_iterator;list(){_head new Node;_head-_next nullptr;_head-_prev nullptr;}~list(){clear();delete[] _head;_head nullptr;}void clear(){iterator it begin();while (it ! end()){erase(it);}}iterator begin(){return iterator(_head-_next);}iterator end(){return iterator(_head);}const_iterator begin() const{return const_iterator(_head-next);}const_iterator end() const{return const_iterator(_head);}void push_back(const T x){Node* tail _head-_prev;Node* newnode new Node(x);newnode-_next _head;newnode-_prev tail;tail-_next newnode;_head-_prev newnode;}private:Node* _head;};};void Test_list1(){listint l;l.push_back(1);l.push_back(2);l.push_back(3);l.push_back(4);listint::iterator it l.begin();while (it ! l.end()){cout *it ;it;}cout endl;}struct Date{int _year;int _month;int _day;Date(int year 0,int month 1,int day 1):_year(year),_month(month),_day(day){}};void Test_list2(){listDate l;l.push_back(Date(2006,9,12));l.push_back(Date(1999,5,6));listDate::iterator it l.begin();while(it ! l.end()){cout it-_year - it-_month - it-_day endl;it;}} void list_print(const listint l){listint::const_iterator it l.begin();while (it ! l.end()){//*it 1;cout *it ;it;}cout endl;}void Test_list3(){listint l;l.push_back(1);l.push_back(2);l.push_back(3);l.push_back(4);l.push_back(5);list_print(l);} }int main() {wkl::Test_list3();return 0; }新手写博客有不对的位置希望大佬们能够指出也谢谢大家能看到这里让我们一起学习进步吧
http://www.pierceye.com/news/356415/

相关文章:

  • 怎么把自己做的网站挂到外网上中文 网站模板
  • 篮球运动装备网站模板昆明网站seo多少钱
  • 建筑网站起名wordpress评论折叠
  • 东莞seo网站推广建设抖音开放平台注册
  • 怎么做淘宝客采集网站建设局考试通知文件网站
  • 百度云网站建设视频教程超市网站设计
  • 主机屋 建网站教程wordpress收费会员插件
  • 天津网站建设的公司哪家好shopify和wordpress
  • 网站设计风格评价天元建设集团有限公司 伊永成
  • 望都网站建设山东的互联网公司都有什么
  • 开发一个网站需要多少人邢台网站建设服务商
  • 钦州建设局网站seo网站关键词优化机构
  • 北京工程信息网站网站建设及管理使用情况汇报
  • 网页网站原型图占位符怎么做公司宣传策划方案
  • 企业网站颜色选择wordpress自然志下载
  • 介绍几个网站重庆网站建设微信开发
  • wordpress小工具跟随最新外贸seo
  • 网站域名的密码电子商务网站策划书3500字
  • 2008 iis 添加 网站 权限设置权限网站开发工程师题
  • 公司域名查询网站网页设计工具软件有哪些
  • 毕业设计网站建设选题依据设计公司网站应该包括的信息
  • wordpress 仪表板主题seo网站排名厂商定制
  • 网站建设成本报表wordpress缺点
  • 外贸建站选择哪个服务器好免费自动生成二维码
  • 建设部申请自己网站c 做网站设计
  • 软件制作网站网站维护合同模板
  • 那家财经网站做的好陕西网站建设公司哪有
  • 淄川网站建设中小型企业网站建设
  • phpcms 投资 网站源码wordpress主题网站
  • 聊城网站托管义乌外贸公司联系方式