在大多数情况下,这是没有错的,因为这本身也是一种初始化方式——拷贝初始化(Copy-initialization)。如同很多定义了拷贝构造函数的类对象一样,这种方式也能完成初始化。
基于12个网页-相关网页
copy initialization 拷贝初始化
For objects of class type, copy-initialization can be used only when specifying a single argument or when we explicitly build a temporary object to copy.
对于类的对象,当指定单一的实参或者为了拷贝明确构建临时对象时,才能使用拷贝初始化。
There are subtle differences between copy - and direct-initialization when initializing objects of a class type.
当初始化类类型对象时,复制初始化和直接初始化之间的差别是很微妙的。
Is there any way to make the implicit copy constructor use initialization lists? Is there any other way around manually writing the initialization list?
有什么方法可以利用隐式的拷贝构造函数初始化列表吗?有没有其他方式手动编写初始化列表吗?
应用推荐