blog.iankulin.com

C

Protocols

Swift structs can’t use inheritance and classes are limited to a single superclass, so protocols fill the gap by letting structs, classes, and enums adopt shared properties and methods. I walk through a C++ multiple inheritance example and its Swift protocol equivalent, showing how a function can accept any type that conforms to a given protocol...