编译器会在 { 开始的地方分配在大括号内所有变量的空间。构造器的调用要到对象定义的地方。
storage allocation
- the compiler allocates all the storage for a scope at the opening brace of scope
- the constructor call does't happen until the sequence point where the object is defined
对象没有构造,如果进行析构会编译不通过。
aggregate initialization
struct Y{float f;float i;Y(int a);}; // Y(int a) 是构造函数
Y y1[]={Y(1),Y(2),Y(3)}; //成员如果没有初始化将导致错误
Y y2[2]={Y(1))}; // 错误, 第二个元素意味着要找到一个默认的构造函数初始化,但是没有就报错了
the default constructor 默认构造函数
- a default constructor is one that can be called with no arguments
自己写的或者编译器给你的那个没有参数的构造函数--->default constructor

943

被折叠的 条评论
为什么被折叠?



