0 votes
in Swift by

What is the difference between class and structure?

1 Answer

0 votes
by

The difference between class and structure are given below:

Classes are reference types, whereas structs are value types.

Classes can be built on other classes, whereas struct cannot inherit from another struct.

Classes have an inheritance, whereas structs cannot have an inheritance.

In class, we can create an instance with “let” keywords and attempt to mutate its property, whereas there is no Mutability in Structs.

Classes have Type Casting, whereas struct doesn’t have Type Casting.

...