The noncopyable class definition presents no surprises, as the copy constructor and operator= are declared private.
noncopyable类定义没有什么令人感到新奇的地方,因为copy constructor和operator= 声明为 private。
In the first case, you are essentially declaring a private copy constructor and then not providing any implementation.
在第一种情况下,你基本上是声明一个私有拷贝构造函数,然后没有提供任何实现。
When it can do so, the compiler is permitted (but not obligated) to skip the copy constructor and create the object directly.
当这种用法被支持时,编译器被允许(但不被制强)跳过复制构造函数而直接创建该对象。
The only other thing to note in Listing 17 is that the definitions for the copy constructor and operator= methods are not provided.
清单17中要注意的另一点是,未提供copy constructor和operator=方法的定义。
Put the functionality you need in separate functions called by the destructor and the copy constructor and the assignment operator.
放在单独的功能调用析构函数和拷贝构造函数和赋值运算符你所需要的功能。
In the first case, you are essentially declaring a private copy constructor and then not providing any implementation. By declaring them private, non-members cannot copy it.
在第一种情况下,你基本上是声明一个私有拷贝构造函数,然后没有提供任何实现。通过声明他们私人,非成员国不能复制它。
Modeling constructor, destructor, and copy constructor.
建模构造函数、分析构造函数,以及拷贝构造函数。
You do not need a copy constructor, and you need never sweat the gory details of implementing a clone method.
您不需要使用复制构造函数,并且永远也不需要大汗淋漓地去实现clone方法的那些令人惨不忍睹的细节。
The copy constructor is a special kind of constructor which creates a new object which is a copy of an existing one, and does it efficiently.
拷贝构造函数是一种特别的构造函数,用于复制已经存在的对象到新生成的对象,这是一种高效的方式。
Your first solution conveys to the reader that the copy-constructor is private and is not to be used.
你的第一个解决方案向读者传达,拷贝构造函数是私有的,不能使用。
The traditional way to solve this is to declare the copy-constructor private and to leave it unimplemented.
传统的方式来解决这个是声明拷贝构造函数私有和未实现的。
When I return by value from an assignment operator, firstly what is the mechanism and basis of calling the copy constructor?
当我返回值赋值操作符,首先是调用复制构造函数为基础的机制?
How else could you use that return instruction to create and return an object and yet not use the copy constructor?
不然你怎么使用返回指令创建并返回一个对象而不使用复制构造函数?
The first case is redundant, why declare the copy constructor, make it private, and not implement it.
第一个病例是多余的,为什么声明拷贝构造函数,使其私人,不实现它。
To manage a class with pointer members, we must define all three copy-control members: the copy constructor, assignment operator, and the destructor.
为了管理具有指针成员的类,必须定义三个复制控制成员:复制构造函数、赋值操作符和析构函数。
It exists for all instances, and to attempt to modify it in the class copy constructor makes little sense (unless you are using it to keep some kind of counter of instances).
它存在的所有实例,并试图修改它的类的复制构造函数是毫无意义的(除非你是用它来保持某种计数器的实例)。
Many developers write the first constructor and then copy and paste the code into other constructors, to satisfy the multiple overrides defined in the class interface.
很多开发者编写第一个构造函数,然后将代码复制粘贴到其它构造函数中去,以满足在类的接口上定义的多个重载。
Even though an implementation is allowed to elide the copy, a viable and accessible copy constructor (or move constructor, if we're talking about a move) should still be present.
虽然实现是允许省略拷贝,一个可行的和可访问的拷贝构造函数(或移动构造函数,如果我们谈论的是一个移动)应该是仍然存在的。
Add output statements to the constructor, destructor and copy constructor to see the effect of the Named Return Value optimization when you run the program.
将输出语句添加到构造函数、析构函数和复制构造函数,以查看在运行程序时命名返回值优化的效果。
Understand and master the constructor, destructor, copy constructor, default constructor and default constructor parameters, to define methods and objects of the structure and the role of withdrawal.
理解并掌握构造函数、析构函数、拷贝构造函数、默认构造函数和缺省参数的构造函数的含义、定义方法以及在对象的构造和撤消中的作用。
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.
问题:手动编写一个拷贝构造函数的初始化每个成员变量作为副本很乏味,和近乎荒谬的成员变量数量的增加。
A copy constructor was not accessible in a base class and was therefore not generated for a derived class.
不可访问基类中的复制构造函数,因此无法为派生类生成复制构造函数。
Often I desire a copy constructor which initializes each member variable as a copy, rather than default constructing and then assigning. e. g.
经常我渴望一个拷贝构造函数初始化成员变量作为一个副本,而不是默认的构造,然后分配。
Often I desire a copy constructor which initializes each member variable as a copy, rather than default constructing and then assigning. e. g.
经常我渴望一个拷贝构造函数初始化成员变量作为一个副本,而不是默认的构造,然后分配。
应用推荐