When children are born, they inherit traits from their parents. Similarly, encode a class can inherit traits from another class. This is called code inheritance. In practice, it's commonly referred to as sub classing. Inheritance describes the sharing of traits between a parent and child class. The parent class refers to the existing class, while the new class that inherits all properties and methods from the parent is called a child class. In short, code inheritance is a process of subclassing a class from another class. You can think of subclass as the common verb for class or object inheritance in programming. Over the next few minutes, you'll discover how to use subclassing and Swift to create a child class that inherits trace from a parent class. Suppose you're developing a gardening game. In this game, you need to program spinach, broccoli, and carrot classes. Spinach broccoli and carrots are vegetables. Knowing this, you can make these classes inherit vegetable traits by subclassing them as a vegetable. This means that you don't have to rewrite the common code between classes, which reduces the overall efforts required to maintain your code. To demonstrate sub classing, let's explore how spinach, broccoli, and carrots can be programmed to sing a special vegetable song for the gardening game. First, I create the parent class by defining a new class called vegetable. Then I add a constant called primary color with its value set to green. Next I create a method called sing that prints, I'm an awesome vegetable. Now I have a vegetable class that has a property and a method. With the vegetable class available, I can now create spinach, broccoli, and carrot classes that inherit the property and method of vegetable. To do this, I'll use this Swift syntax for subclassing. I start by inserting the keyword class followed by the child class name, in this case, spinach. Next, I insert a colon followed by the parent class vegetable, and then I add curly braces. I'll do the same for broccoli and carrots. Now I have three new clauses, spinach, broccoli, and carrots, which are all child classes of a vegetable parent. To demonstrate that spinach broccoli and carrot inherit properties and methods from vegetable, I'll initialize each child class print its primary color property, and call the sing method on it. To do this, I create three new constants for spinach, broccoli, and carrots, and set the values equal to their respective class. Next, I print each primary color. Finally, I call the same method on spinach, broccoli, and carrots. When I run the code, the outputs from each class is the same. All the vegetables print green and sing the same. I'm an awesome vegetable song. But what if I want to differentiate the child from its parent class? To do this, I can override the parents properties and methods in the child class. You can think of properties and methods override as altering the parent class DNA for a child class. A common use case for altering the DNA of a child class is when you want to keep a set of properties and methods the way they are. However, you want to differentiate one or a few properties or methods for the child class. If you want a child class to have a different property value and its parents, you can override the parent property. For instance, I'd like to override the primary color property of the carrot class from green to orange, I insert the override keyword to declare the intention of replacing the primary color value of the parent class with orange. With the newly added code, the compiler greets me with an error that reads, cannot override it with a stored property primary color. This is because I cannot override a stored property, but I can override a computed property. To demonstrate this, I change vegetables primary color stored property to a computed property. Now I can successfully override the primary color property in the carrot class. When I run my code, the console log prints orange, it is clear that the carrot class overrides the primary color of the parent class. Let's try something similar with broccoli. I want broccoli to sing a different song. To do this, I override the sing method inside the broccoli class. Then inside the override sing method, I invoke the parents method by using the super keyword followed by a dot and the desired parent method. When I execute my code, I can observe that the broccoli class sings a three line song in the console log. There you have it. You should now be able to demonstrate how subclassing and inheritance enable you to share properties and methods between parent and child classes. You should also be able to differentiate a child class by overriding its parent properties and methods.