- Object–Oriented Programming with Swift 2
- Gastón C. Hillar
- 169字
- 2021-07-23 14:29:41
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.
- Bootstrap Site Blueprints Volume II
- Mastering JavaScript Functional Programming
- Visual Basic .NET程序設計(第3版)
- Learn Type:Driven Development
- 企業級Java EE架構設計精深實踐
- Mastering Objectoriented Python
- Cassandra Design Patterns(Second Edition)
- INSTANT MinGW Starter
- UI智能化與前端智能化:工程技術、實現方法與編程思想
- 人臉識別原理及算法:動態人臉識別系統研究
- Java持續交付
- INSTANT Passbook App Development for iOS How-to
- R Deep Learning Cookbook
- PySide 6/PyQt 6快速開發與實戰
- Java系統化項目開發教程