While classes and structures are very similar, there are also several very important differences. The following is a list of some of the differences between classes and structures in Swift:
- Type: A structure is a value type, while a class is a reference type
- Inheritance: A structure cannot inherit from other types, while a class can
- Deinitializers: Structures cannot have custom deinitializers, while a class can
Throughout this chapter, we will be emphasizing the differences between classes and structures to help us understand when to use each. Before we really dive into classes and structures, let's look at the difference between value types (structures) and reference types (classes). To fully ...