• Do classes that should not be instantiated have a private constructor?

    不需要实例化的类有私有构造函数吗?

    youdao

  • If a class contains only static members, remember to mark the class as static or seal the class (NotInheritable) and give the class a private constructor to avoid instance creation.

    如果类只包含静态成员,则要记得将该类标记为静态,或者密封该类(NotInheritable),并且还要为该类提供一个私有构造函数,以避免实例创建。

    youdao

  • Listing 2 shows a piece of code that results in a compile-time error because the copy constructor is private.

    清单2显示了产生编译时错误的代码部分,因为该拷贝构造函数是私有的。

    youdao

  • You should mark this constructor private so that you can't accidentally call the constructor and forget to record it in your object map.

    应当将此构造器标识为私有,这样就不会意外调用构造器并忘记将它记录到对象映射中。

    youdao

  • The argument to the constructor is the fully qualified URL of the metadata service being exposed, which we construct using methods in the private class HostDescriptor.

    该构造函数的参数是正在被显示的元数据服务的全限定url,我们使用私有类HostDescriptor中的方法构造了它。

    youdao

  • HierarchyBuilder's constructor is private, however, so I can't test it via my test class (nor do I care to); therefore, my line coverage still hovers at 88%.

    然而,因为HierarchyBuilder的构造器是private类型的,所以我不能通过我的测试类测试它(我也不关心)。因此,我的行覆盖率仍然只有88%。

    youdao

  • Also, for classes that have design reasons to have private or no copy constructor, this style of swapping won't work. Here's what boost: : swap gets you.

    另外,对于出于设计原因拥有private构造函数而没有复制构造函数的类,所以这种交换风格不适用。

    youdao

  • If you're using a framework that requires this for some reason, see if you can satisfy it by providing a private no-argument constructor (which is visible via reflection).

    如果您正在使用的框架因为某些原因需要使用这样的构造函数的话,那么您可以了解以下能否通过提供一个私有的无参数构造函数(这是经由反射可见的)来满足这一要求。

    youdao

  • The noncopyable class definition presents no surprises, as the copy constructor and operator= are declared private.

    noncopyable类定义没有什么令人感到新奇的地方,因为copyconstructor和operator= 声明为 private。

    youdao

  • Your first solution conveys to the reader that the copy-constructor is private and is not to be used.

    你的第一个解决方案向读者传达,拷贝构造函数是私有的,不能使用。

    youdao

  • The traditional way to solve this is to declare the copy-constructor private and to leave it unimplemented.

    传统的方式来解决这个是声明拷贝构造函数私有和未实现的。

    youdao

  • Which is the difference between declaring a constructor private and =delete?

    声明一个构造函数的区别是私人和=删除?。

    youdao

  • The special constructor used for serialization should also perform thorough input validation and should be either protected or private to help protect against misuse by malicious code.

    用于序列化的特殊构造函数也应当进行彻底的输入验证,并且应当成为被保护的或者私有的,以帮助防范恶意代码的滥用行为。

    youdao

  • Do declare static classes as sealed and abstract, and add a private instance constructor, if your programming language does not have built-in support for static classes.

    如果编程语言没有对静态类的内置支持,则应将静态类声明为密封的和抽象的,并添加一个私有实例构造函数。

    youdao

  • In the first case, you are essentially declaring a private copy constructor and then not providing any implementation.

    在第一种情况下,你基本上是声明一个私有拷贝构造函数,然后没有提供任何实现。

    youdao

  • If a static constructor is not private, it can be called by code other than the system.

    如果静态构造函数不是私有,则系统以外的代码可以调用它。

    youdao

  • The programming language compiler added a default static constructor to your type and did not make it private.

    编程语言编译器已向您的类型中添加默认静态构造函数,但未将其设置为私有。

    youdao

  • So just making a constructor private doesn't communicate the intention very well, and the resulting error is not very clear, either.

    所以仅仅做一个构造函数私有并不交流意图很好,和由此产生的错误也不是很清楚,。

    youdao

  • Note that if you do not use an access modifier with the constructor it will still be private by default.

    注意,如果您不对构造函数使用访问修饰符,则在默认情况下它仍为私有构造函数。

    youdao

  • The constructor still exists, but it is private, and can only be invoked from within another class member function.

    构造函数仍然存在,但它是私人的,只能从内部调用另一个类的成员函数。

    youdao

  • The constructor still exists, but it is private, and can only be invoked from within another class member function.

    构造函数仍然存在,但它是私人的,只能从内部调用另一个类的成员函数。

    youdao

$firstVoiceSent
- 来自原声例句
小调查
请问您想要如何调整此模块?

感谢您的反馈,我们会尽快进行适当修改!
进来说说原因吧 确定
小调查
请问您想要如何调整此模块?

感谢您的反馈,我们会尽快进行适当修改!
进来说说原因吧 确定