对于类的对象,当指定单一的实参或者为了拷贝明确构建临时对象时,才能使用拷贝初始化。
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.
如果你没有为拷贝构造函数写正确的代码,就有可能造成list中对象的某些数据成员没有初始化。
If you do not write a correct code for the copy constructor, object within a list will have some data members uninitialized.
在源数据库上初始化镜像拷贝。
赋值运算符是应用于一个初始化的对象,但这并不是拷贝构造函数的情况下。
The assignment operator is applied on a initialized object, but this is not the case in the copy constructor.
问题:手动编写一个拷贝构造函数的初始化每个成员变量作为副本很乏味,和近乎荒谬的成员变量数量的增加。
Question: Manually writing a copy constructor which initializes each member variable as a copy is very tedious, and verges on ridiculous as the number of member variables grows.
有什么方法可以利用隐式的拷贝构造函数初始化列表吗?有没有其他方式手动编写初始化列表吗?
Is there any way to make the implicit copy constructor use initialization lists? Is there any other way around manually writing the initialization list?
有什么方法可以利用隐式的拷贝构造函数初始化列表吗?有没有其他方式手动编写初始化列表吗?
Is there any way to make the implicit copy constructor use initialization lists? Is there any other way around manually writing the initialization list?
应用推荐