
constructor
词源
源自拉丁语 'constructor'(建造者),由 'con-'(共同)和 'struere'(堆积)组成,14世纪通过古法语进入英语。
noun
❶ 构造函数,编程术语,指在创建对象时自动调用的特殊方法,用于初始化对象的属性和状态。
“The constructor is called when a new object is created.”
(创建新对象时会自动调用构造函数。)
“You can define multiple constructors with different parameters.”
(可以通过不同参数定义多个构造函数。)
❶ 建筑者,指实际参与建筑物施工的工人或公司,负责将设计图纸转化为实体结构。
“The constructor promised to finish the building by December.”
(建筑承包商承诺在12月前完成这栋楼。)
“We need to hire a reliable constructor for this project.”
(我们需要为这个项目雇佣可靠的建筑公司。)
常见短语
default constructor — 编程术语,指不带参数的构造函数,当用户未定义任何构造函数时由编译器自动生成。
“If you don't write any constructor, the compiler provides a default constructor.”
(如果未编写任何构造函数,编译器会自动提供默认构造函数。)
copy constructor — 特殊构造函数,用于通过现有对象创建新对象,实现对象内容的复制。
“The copy constructor creates a new object as a copy of an existing object.”
(拷贝构造函数通过复制现有对象来创建新对象。)