全部书籍

专业

应用 关于 Coach 登录 开始阅读

书籍暂未推出简体中文版——当前显示英文版。

Computer Science · 术语表

什么是 Constructor?

Definition 23.2 High School Computer Science · 第 23 章 — Classes and Objects

The constructor of a class is the method that gives a new instance its first attributes. In Python it is named __init__, and it runs when the class is called: Point(3, 4).

One class, three objects. The class holds the methods once; each object holds its own attributes. Two names, b and c, refer to the same object; d is a different object with equal values.
One class, three objects. The class holds the methods once; each object holds its own attributes. Two names, b and c, refer to the same object; d is a different object with equal values.
在原文中阅读 →