- 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.
- Cocos2d Cross-Platform Game Development Cookbook(Second Edition)
- Learning Python Web Penetration Testing
- Spring Cloud Alibaba微服務架構設計與開發實戰
- Mastering Concurrency in Go
- Python機器學習編程與實戰
- R Data Analysis Cookbook(Second Edition)
- Python深度學習原理、算法與案例
- UNIX Linux程序設計教程
- Java EE企業級應用開發教程(Spring+Spring MVC+MyBatis)
- 3ds Max印象 電視欄目包裝動畫與特效制作
- 零基礎學C語言(升級版)
- Hacking Android
- 游戲設計的底層邏輯
- Internet of Things with Arduino Cookbook
- Mastering Swift 4(Fourth Edition)