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

专业开发网站建设哪家好四川百度推广排名查询

专业开发网站建设哪家好,四川百度推广排名查询,物业服务网站建设,网络技术培训心得体会auto 自动推导的规则很多、很细,当涉及移动语义、模板等复杂的规则时,很容易绕进去。因此,在使用 auto 进行自动推导时,牢记以下几点: auto 推导出的是 “值类型”,不会是 “引用类型”。auto 可以和 cons…

auto 自动推导的规则很多、很细,当涉及移动语义、模板等复杂的规则时,很容易绕进去。因此,在使用 auto 进行自动推导时,牢记以下几点:

  • auto 推导出的是 “值类型”,不会是 “引用类型”。
  • auto 可以和 const、& 这些类型修饰符结合,得到新的类型;在自动推导时,先不考虑额外的修饰,看看推导出的是什么类型,然后再加上修饰符。
  • 类成员变量初始化时,不允许使用 auto 推到类型。

普通类型推导

auto p = new int(20);   // p 的类型为 int*auto str1 = "hello";     // str1 的类型C风格字符串 const char*,至于为什么是const,很好理解,"hello" 是字面值即常量auto str2 = "hello"s;    // str2 的类型为 string,需要打开名字空间 using namespace std::literals::string_literals(C++14及之后)auto str3 = std::string("hello");auto r = &str2;     // string*auto i = 1;     // intauto l = 2L;    // longauto ll = 3LL;  // long longauto f = 1.23f; // floatauto d = 3.1415926535;  // doubleauto vec_init = {1, 2, 3, 4, 5};        // std::initializer_list<int>auto vec = std::vector<int>{1, 2, 3, 4, 5};     // std::initializer_list<int>
}

和 const、volatile、*、& 结合

与 const 结合

const auto i = 10;          // const int
const auto f = 0.23f;       // const float
const auto d = 1.234345;    // const doubleconst auto s = std::string("hello");    // const stringconst auto vec_init = {1, 2, 3, 4, 5};        // std::initializer_list<int>
const auto vec = std::vector<int>{1, 2, 3, 4, 5};     // std::initializer_list<int>auto ch = "hello";          // const char *
const auto chr = "hello";   // const char *const

一个需要注意的点是,当使用字符串字面值推导时,推导出的时 const char * ,而当与 const 结合时,推导出的是 const char *const

与 & 结合

auto 根据表达式的结果推导变量类型,推导的是值类型。因此若希望推导的是引用类型,则需要和 & 结合。

auto i = 10;    // int
auto &ri = i;   // int&auto &r = 10;   // 错误,r被推导出 int&,而左值引用不能绑定右值auto &&r = 10;  // 正确,rr被推导出 int&&,右值引用只能绑定右值
int getInt() {int num = 1;return num;
}auto i = getInt();      // int
auto &r = getInt();     // 错误,getInt()返回的是将亡对象,是右值
auto &&rr = getInt();   // 正确,int&&,右值引用绑定到右值

待补充。。。(2023年10月23日)

http://www.ds6.com.cn/news/66586.html

相关文章:

  • 网站百度不收录了sem竞价推广公司
  • 陕西省建设厅网站品牌营销公司
  • 动漫设计工作室网站宣传片制作品牌网络seo方案外包
  • java视频教学网站开发chrome官网下载
  • 上海电商网站开发公司百度网页版链接地址
  • jeecms做企业网站seo投放营销
  • 专做秒杀活动的网站百度推广技巧方法
  • 牛杂网这类网站怎么做的sem广告投放是做什么的
  • 营销网站建设哪里好薇网络推广和网站推广平台
  • 学3dmax学费一般多少西安seo专员
  • 阿里云网站托管贴吧aso优化贴吧
  • 网站seo软件百度大全免费下载
  • 企业网站模板下载需谨慎怎么优化百度关键词
  • 怎样做理财网站网站诊断分析
  • 中企动力做的网站升级收费关联词有哪些 全部
  • 俄语企业网站制作日本搜索引擎naver入口
  • 九江建设监督网站广告策划方案怎么做
  • 东莞seo广告宣传百度seo怎么优化
  • 加盟类网站怎么做网站关键词优化推广
  • 中南集团中南建设网站宁波seo教程行业推广
  • 免费建立自己的网站代理电商网站建设 网站定制开发
  • 网站的主要内容自己建网站要多少钱
  • 网站怎么做404 301企业网站官网
  • 有哪些做海报好的网站seo代做
  • 个人网站 备案 名称seo排名优化培训网站
  • 做阳具到哪个网站有卖优化 英语
  • wordpress 团购许昌seo推广
  • 织梦网站更换域名上海网络推广公司网站
  • 有网站了怎么做app国内高清视频素材网站推荐
  • 淄博高端网站建设合肥网站推广助理