官术网_书友最值得收藏!

Declaring classes

The following lines declare a new minimal Circle class in Swift:

class Circle {
}

The class keyword, followed by the class name (Circle), composes the header of the class definition. In this case, the class doesn't have a parent class or superclass; therefore, there are neither superclasses listed after the class name, nor a colon (:). A pair of curly braces ({}) encloses the class body after the class header. In the forthcoming chapters, we will declare classes that inherit from another class, and therefore, they will have a superclass. In this case, the class body is empty. The Circle class is the simplest possible class we can declare in Swift.

Tip

Any new class you create that doesn't specify a superclass is considered a base class. Whenever you declare a class without a subclass, the class doesn't inherit from a universal base class, as it happens in other programming languages such as C#. Thus, the Circle class is known as a base class in Swift.

主站蜘蛛池模板: 达日县| 论坛| 合作市| 吴旗县| 马鞍山市| 大新县| 三亚市| 定襄县| 建阳市| 化州市| 霍邱县| 武邑县| 梨树县| 沂水县| 南安市| 明溪县| 波密县| 邯郸县| 临潭县| 松潘县| 石阡县| 灵璧县| 尤溪县| 杂多县| 江安县| 庆安县| 北京市| 潼关县| 贡嘎县| 资溪县| 西安市| 吴江市| 宝丰县| 林州市| 类乌齐县| 肇源县| 定边县| 米泉市| 四川省| 桂阳县| 潜江市|