• 如果你的成员是POD类型的,那么list initialization和constructor initialization没有任何区别
#include<iostream>
using namespace std; class A
{
int a;
double b;
A() :a(0), b(0.0)//结构体初始化
{ }
A(int a_in, double b_in) :a(a_in), b(b_in)//结构体初始化
{}
~A() {} };
class B
{
int a;
double b;
B()//列表初始化
{
a = 0;
b = 0.0;
}
B(int a_in, double b_in)//列表初始化
{
a = a_in;
b = b_in;
}
~B() {} };
int main()
{
system("pause");
}
  •   但是成员变量的类型是非POD类型,比如自定义类型,那么list inlitialization的代码就会变成
#include<iostream>
using namespace std; struct A
{ int a;
A() { ; }
A(int a_in) :a(a_in)
{ }
};
struct B
{
double b;
B() {}
B(double b_in):b(b_in)
{ }
};
class D
{
A a1;
B b1;
//D(int a, double b) :a1(a), b1(b)//结构体初始化,这个也是正确的
//{}
D(int a, double b)//列表初始化
{
a1 = a;//这里如果不给A B写无参构造函数会出错
b1 = b;
}
}; int main()
{
system("pause");
}

  但是这里仍旧不知道列表初始化和结构体初始化的区别以及运算时间的长短

关于POD和非POD类型中,list initialization和constructor initialization(未解决)的更多相关文章

  1. BootStrap中关于input-group的问题(未解决)

    ****************************************2016年1月6日 23:08******************************* 本来想实现的如下功能: 但 ...

  2. 二元谓词中添加const的问题(未解决)

    #include <iostream> using namespace std; #include"set" #include"algorithm" ...

  3. pod(八):pod的调度——将 Pod 指派给节点

    目录 一.系统环境 二.前言 三.pod的调度 3.1 pod的调度概述 3.2 pod自动调度 3.2.1 创建3个主机端口为80的pod 3.3 使用nodeName 字段指定pod运行在哪个节点 ...

  4. 十三、Pod的资源控制器类型

    Pod 的资源控制器类型 一.Pod 的资源控制器类型 什么是控制器呢?简单来说,控制器就好比是影视剧里面的剧本,演员会根据剧本所写的内容来针对不同的角色进行演绎,而我们的控制器就好比是剧本,Kube ...

  5. 在javaScript中把非数值类型的数据自动转换为数值类型的两种方式

    一.使用Number()函数. 二.使用parseInt()/parseFloat()函数. 详情: 一.使用Number()函数将非数值类型的数据自动的转化为数组类型 Number()函数可以将任何 ...

  6. 未经处理的异常在 System.Data.dll 中发生。其它信息:在应使用条件的上下文(在 &#39;***&#39; 附近)中指定了非布尔类型的表达式。

    机房收费系统中,有些人在联合查询这个模块用的是存储过程.我先尝试着在数据库中建立了一个视图.然后在UI层做个推断并生成查询条件strCondition. 在机房收费系统的"联合查询" ...

  7. SpringMVC中使用@Value给非String类型注入值

    String类型的@Value注入方式 String类型的直接可以使用 @Value("陈婉清") private String name; 非String类型的@Value注入方 ...

  8. 使用 pod install 还是 pod update ?

    翻译自:https://guides.cocoapods.org/using/pod-install-vs-update.html 介绍: 许多人开始使用CocodPods的时候认为pod insta ...

  9. pod install 和 pod update的区别

    pod install 和 pod update的区别 pod install(下载并安装pod) 1,当pod file文件中有“增加pod,删除pod,修改pod”的操作之后使用. 2,pod i ...

随机推荐

  1. (转)Paper list of Meta Learning/ Learning to Learn/ One Shot Learning/ Lifelong Learning

    Meta Learning/ Learning to Learn/ One Shot Learning/ Lifelong Learning 2018-08-03 19:16:56 本文转自:http ...

  2. Joint Detection and Identification Feature Learning for Person Search

    Joint Detection and Identification Feature Learning for Person Search 2018-06-02 本文的贡献主要体现在: 提出一种联合的 ...

  3. (转) AdversarialNetsPapers

      本文转自:https://github.com/zhangqianhui/AdversarialNetsPapers AdversarialNetsPapers The classical Pap ...

  4. 【C#】取整函数Math.Round、Math.Ceiling和Math.Floor区别

    Math.Round 原则: 四舍六入五取偶. 也就是说 0.1-0.4为0 0.5为0 0.6-0.9为1 1.5为2 Math.Ceiling 原则: 有小数就加1 0.1 = 1 Math.Fl ...

  5. maven web项目生成WebContent或WebRoot目录

    本文为博主原创,转载请注明出处: 新建maven web工程时,自动生成的文件结构目录如下: 这个是maven web自动生成的目录结构,我想让其生成如java web工程的WebRoot 或WebC ...

  6. Robot Framework+AutoItLibrary使用

    目的:用Robot Framework测试win7桌面程序   因为安装完了才补的记录,估计有错漏:(     步骤: 1. 尝试pip install AutoItLibrary 失败 2. 下载A ...

  7. pyqt5 窗口无边框和透明

    https://blog.csdn.net/FanMLei/article/details/79433229 按钮圆形方法属性border-radius:30px; QScrollArea 无法滚动用 ...

  8. AngularJS 笔记2

    2017-03-23 本文更新链接: http://www.cnblogs.com/daysme/p/6613071.html $http angularjs中的ajax 向服务器请求数据 1/2 后 ...

  9. zepto 入门

    2017-03-17 文章来源:http://www.cnblogs.com/daysme zepto 简介 jq虽然有一些衍生的插件可用在移动端上,但它有点大. click 有,但有问题 onmou ...

  10. oracle批量删除某用户下的表

    昨天干了一天的体力活,到快下班时被要求删除一批测试库上错误的表,主要是这些表的字段和生产上字段顺序对不上,然后让我写个脚本,让dba执行一下,主要是删表这种东西我们都没权限. 然后,我就被难到了,我记 ...