网站首页  英汉词典

请输入您要查询的英文单词:

 

单词 Default constructor
释义

Default constructor

中文百科

缺省构造函数

缺省构造函数是C++及其他一些面向对象进程设计语言中,对象的不需要参数即可调用的构造函数。对象生成时如果没有显式地调用构造函数,则缺省构造函数会被自动调用。C++标准规定,如果构造函数没有参数(nullary),或者构造函数的所有参数都有缺省值(default value),都算作缺省构造函数。一个类只能有一个缺省构造函数。

例如,显式定义、使用“缺省构造函数”:

下述例子是动态生成对象时,显示调用了缺省构造函数:

C++中,缺省构造函数会在下列情形被自动调用:

在上述这些情形中,如果被初始化地对象没有缺省构造函数,则编译时报错。

英语百科

Default constructor 缺省构造函数

In computer programming languages the term default constructor can refer to a constructor that is automatically generated by the compiler in the absence of any programmer-defined constructors (e.g. in Java), and is usually a nullary constructor. In other languages (e.g. in C++) it is a constructor that can be called without having to provide any arguments, irrespective of whether the constructor is auto-generated or user-defined. Note that a constructor with formal parameters can still be called without arguments if default arguments were provided in the constructor's definition.

随便看

 

英汉网英语在线翻译词典收录了3779314条英语词汇在线翻译词条,基本涵盖了全部常用英语词汇的中英文双语翻译及用法,是英语学习的有利工具。

 

Copyright © 2004-2024 encnc.com All Rights Reserved
更新时间:2025/6/21 13:05:59