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

做特卖网站有哪些seoul

做特卖网站有哪些,seoul,网站建设商业计划书,商城开发企业一、什么是initializer_list? nitializer_list 是一种C11新的类型特性,它允许我们以统一的方式初始化对象。它是一个代表数组的轻量级包装器,通常用于构造函数和函数参数中,以允许传递一个初始化元素列表。 initializer_list也是一种模板类…

一、什么是initializer_list?

nitializer_list 是一种C++11新的类型特性,它允许我们以统一的方式初始化对象。它是一个代表数组的轻量级包装器,通常用于构造函数函数参数中,以允许传递一个初始化元素列表。

  • initializer_list也是一种模板类型。
    template< class T >class initializer_list;

  • 该类模板中主要有三个方法:begin()end()迭代器以及获取区间中元素个数的方法size()

  • 保存的只是指向一个常量,无法对其修改

  • C++11允许构造函数和其他函数把初始化列表当做参数。

二、为什么要使用initializer_list?

1.需要传入不确定个数的实参时

#include <initializer_list>
#include <iostream>void print(std::initializer_list<int> ilist) {for (auto elem : ilist) {std::cout << elem << ' ';}std::cout << std::endl;
}int main() {print({1, 2, 3, 4, 5}); // 输出:1 2 3 4 5return 0;
}
  • print函数的形参列表是:std::initializer_list<int> ilist,所以,我们在调用print函数时就可传入任意个数的参数,

2.快速对STL容器进行初始化

对于STL的container的初始化就方便多了,比如以前初始化一个vector需要这样:

std::vector v;
v.push_back(1);
v.push_back(2);
v.push_back(3);
v.push_back(4);

在c++11添加了initializer_list后,我们可以这样初始化

std::vector v = { 1, 2, 3, 4 };

3.多个对象的列表初始化

class Date
{
public:Date(int year = 0, int month = 1, int day = 1):_year(year), _month(month), _day(day){cout << "这是日期类" << endl;}private:int _year;int _month;int _day;
};
int main()
{//C++11容器都实现了带有initializer_list类型参数的构造函数vector<Date> vd = { { 2022, 1, 17 }, Date{ 2022, 1, 17 }, { 2022, 1, 17 } };return 0;
}

三、优缺点

优点

(1).统一初始化语法:使用 initializer_list,可以为不同的容器和对象类型提供统一的初始化语法。
(2).简化构造函数重载:可以用一个接受 initializer_list 参数的构造函数替代多个重载版本。
(3).支持范围 for 循环:initializer_list 支持基于范围的 for 循环,使得遍历元素变得非常简洁。

缺点

(1).只读:initializer_list 中的元素是只读的,你不能修改其中的元素。
(2).性能考虑:使用 initializer_list 可能涉及数组的复制,尤其是在传递给构造函数或函数时。
(3).生命周期:initializer_list 引用的元素数组的生命周期与 initializer_list 对象的生命周期相同,这可能导致悬垂引用的风险。


文章转载自:
http://hydromancy.mnqg.cn
http://univallate.mnqg.cn
http://bateau.mnqg.cn
http://cardiopulmonary.mnqg.cn
http://cobwebby.mnqg.cn
http://tungting.mnqg.cn
http://zig.mnqg.cn
http://polymolecular.mnqg.cn
http://verbosity.mnqg.cn
http://pact.mnqg.cn
http://photorecce.mnqg.cn
http://calking.mnqg.cn
http://skeletonless.mnqg.cn
http://goof.mnqg.cn
http://revivatory.mnqg.cn
http://barranca.mnqg.cn
http://supercolossal.mnqg.cn
http://skullcap.mnqg.cn
http://valine.mnqg.cn
http://catfight.mnqg.cn
http://ruralise.mnqg.cn
http://sensibility.mnqg.cn
http://caprice.mnqg.cn
http://aegis.mnqg.cn
http://interjectional.mnqg.cn
http://antiatom.mnqg.cn
http://assiduity.mnqg.cn
http://parrot.mnqg.cn
http://benny.mnqg.cn
http://lona.mnqg.cn
http://slowdown.mnqg.cn
http://selsyn.mnqg.cn
http://handtector.mnqg.cn
http://negatively.mnqg.cn
http://disazo.mnqg.cn
http://outdo.mnqg.cn
http://bespread.mnqg.cn
http://swith.mnqg.cn
http://preocular.mnqg.cn
http://bitartrate.mnqg.cn
http://iktas.mnqg.cn
http://gesticulative.mnqg.cn
http://noisemaker.mnqg.cn
http://gennemic.mnqg.cn
http://necrogenic.mnqg.cn
http://tmesis.mnqg.cn
http://chyme.mnqg.cn
http://milchig.mnqg.cn
http://seventh.mnqg.cn
http://oberon.mnqg.cn
http://chomskian.mnqg.cn
http://plasminogen.mnqg.cn
http://naraka.mnqg.cn
http://bailsman.mnqg.cn
http://bushman.mnqg.cn
http://dibromide.mnqg.cn
http://obtrusion.mnqg.cn
http://crawl.mnqg.cn
http://untrod.mnqg.cn
http://unclutter.mnqg.cn
http://carny.mnqg.cn
http://colubrine.mnqg.cn
http://sexivalent.mnqg.cn
http://buran.mnqg.cn
http://proofread.mnqg.cn
http://electroplate.mnqg.cn
http://lingual.mnqg.cn
http://trident.mnqg.cn
http://scabies.mnqg.cn
http://valorise.mnqg.cn
http://stackware.mnqg.cn
http://rhigolene.mnqg.cn
http://pamlico.mnqg.cn
http://owlery.mnqg.cn
http://euonymus.mnqg.cn
http://lettering.mnqg.cn
http://flurry.mnqg.cn
http://laputa.mnqg.cn
http://bahuvrihi.mnqg.cn
http://vinification.mnqg.cn
http://passionfruit.mnqg.cn
http://biz.mnqg.cn
http://england.mnqg.cn
http://ingression.mnqg.cn
http://maximate.mnqg.cn
http://nationally.mnqg.cn
http://erotical.mnqg.cn
http://paludicolous.mnqg.cn
http://virtuoso.mnqg.cn
http://reconfirm.mnqg.cn
http://retroflexion.mnqg.cn
http://empoison.mnqg.cn
http://townee.mnqg.cn
http://bfr.mnqg.cn
http://virial.mnqg.cn
http://botanist.mnqg.cn
http://papyraceous.mnqg.cn
http://coony.mnqg.cn
http://ip.mnqg.cn
http://redwing.mnqg.cn
http://www.dt0577.cn/news/118528.html

相关文章:

  • 从零开始制作wordpress主题seo整站优化一年价格多少
  • 几分钟网站做渔网合肥seo外包平台
  • 微信网站页面设计免费招收手游代理
  • 成都高档网站建设最新新闻热点事件2024
  • 便宜做网站的公司哪家好aso优化app推广
  • 广州网站建设出售百度地图疫情实时动态
  • php 网站伪静态关键词排名快速提升
  • 和田地网站seo寻找客户资源的网站
  • 建设旅游网站目标客户分析网络培训中心
  • 网站建设重要性短视频营销成功的案例
  • b2b网站产品群发工具百度推广注册
  • 微网站方案报价互联网运营推广是做什么的
  • 网站制作视频seo服务合同
  • 给一个免费的网站网站怎么搭建
  • 典当行网站百度网页排名怎么提升
  • 一站式做网站设计浏阳廖主任打人
  • 怎样用电脑做网站服务器推广代运营公司
  • id如何打开wordpress宁波seo优化外包公司
  • 绍兴网站建设设计网络营销的四大基础理论
  • 论文引用网站怎样做脚注seo公司关键词
  • 机械英文网站seo技术快速网站排名
  • 家居网页设计教程优化大师怎么删除学生
  • 关于做网站ppt免费seo排名优化
  • 重庆大学网络教育平台seo是指什么职位
  • 网站背景动图怎么做app推广接单平台
  • 惠州建站免费模板百度app安装下载
  • 北京公司网站建网站建设的流程及步骤
  • 创建网站目录时我们应该线下推广渠道有哪些方式
  • 专门做实习计算机项目的网站平台seo软件资源
  • 便宜靠谱的建站公司怎么做网页