在cpp中,我们可以将原始数据类型初始化为
int a(32);
这个构造函数初始化是如何工作的? C++ 是否将其视为对象?
最佳答案
最好的描述是:
C++03 8.5 初始化器
第 12 和 13 段:
.......
The initialization that occurs in new expressions (5.3.4), static_cast expressions (5.2.9), functional notation type conversions (5.2.3), and base and member initializers (12.6.2) is called
direct-initialization and is equivalent to the formT x(a);
If T is a scalar type, then a declaration of the form
T x = { a };
is equivalent to
T x = a;
在问题中,类型是 int
,它是标量类型。
关于c++ - CPP中原始数据类型的构造函数初始化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10843715/