一个拷贝构造器(copy constructor)是用来通过一个个体来初始化另外一个个体,而一个拷贝赋值操作符(copy assignment operator)是用来将一个个体的值拷贝到另外一...
基于90个网页-相关网页
如果程序员没有提供拷贝构造函数,那么编译器会自动生成默认的拷贝构造函数。默认的拷贝构造函数会执行简单的操作,即按位拷贝对象。
Default copy constructor does a very simple operation, they will do a bit-wise (member-wise) copy of an object, which means that the object will be copied bit by bit.
注意:实际上在这种情况下,编译器是会对拷贝构造进行优化的。
Note: the compiler is actually allowed (but not required) to optimize away the copy construction in this kind of situation.
再一次,如果你不提供一个拷贝构造函数,编译器生成一个你,再一次复制使用拷贝构造函数成员。
Again, if you don't provide a copy constructor, the compiler generates one for you, again just copying the members using the copy constructor.
应用推荐