Skip to content

Commit 493bf3b

Browse files
committed
Content: What is the difference between struct and class? (edited)
1 parent 4cfad73 commit 493bf3b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,9 @@ Some classes of libraries and frameworks are not designed to be subclasses. For
295295

296296
#### What is the difference between a struct and a class?
297297

298-
Structs are value types while classes are reference types. Classes have capabilities that structs do not:
298+
The main difference to note is that structs are value types (stored on stack) while classes are reference types (stored on heap).
299+
300+
Classes have capabilities that structs do not:
299301
- Inheritance enables one class to inherit the characteristics of another. ([source](https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/ClassesAndStructures.html))
300302
- Type casting enables you to check and interpret the type of a class instance at runtime.
301303
- Deinitializers enable an instance of a class to free up any resources it has assigned.

0 commit comments

Comments
 (0)