全部书籍

专业

应用 关于 Coach 登录 开始阅读

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

Computer Science · 术语表

什么是 Inheritance, subclass, overriding?

又称: subclass · inheritance · overriding

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

A subclass is a class defined from another, its base class, by inheritance: it has all the base class’s methods, and may add others. A method of the subclass with the same name as one of the base class overrides it: it replaces it for the instances of the subclass.

The classes of shapes.py. An arrow goes from a subclass to its base class. describe is inherited by all; area is overridden; Square only changes the constructor, through super().
The classes of shapes.py. An arrow goes from a subclass to its base class. describe is inherited by all; area is overridden; Square only changes the constructor, through super().
在原文中阅读 →