Learn About Inheritance in Programming Languages


show more Programming quickly and effectively is all about reusing code and keeping it as clean as possible. Inheritance is one function that helps eliminate the need to create completely new classes in object-oriented programming. What is inheritance? Think of inheritance in programming like making a clone. The new set will have everything the old set has, but with the option to add new information and functions. Learn how to set up and implement inheritance to cut down on your programming time. show less
please wait ...

What is inheritance?

This next idea of Inheritance is first a great form of code reuse. We can create a new class, but instead of writing it from scratch, we can base it on an existing class. So let's say you start off by defining in your application a Person class with a few attributes--name and address and phone number, and perhaps some simple behavior in it--and then later on you figure out your application will need another class, and this one called Customer. But you realize as you are writing it that this new Customer class is exactly the same as the Person class, and the only difference is it also has a customerNumber.

Now, you didn't want to add that customer number to your Person class, because we're trying to use abstraction. We're trying to only focus on the essentials, and not all of your Person objects will be customers. Now, you could do this by creating a completely separate class, but in an Object-Oriented language, a better way is that we'll create a new class called Customer, and the...

What is inheritance?
Video duration: 3m 35s 3h 1m Intermediate

Viewers:

Programming quickly and effectively is all about reusing code and keeping it as clean as possible. Inheritance is one function that helps eliminate the need to create completely new classes in object-oriented programming. What is inheritance? Think of inheritance in programming like making a clone. The new set will have everything the old set has, but with the option to add new information and functions. Learn how to set up and implement inheritance to cut down on your programming time.

Subject:
Developer
Software:
Java
Author:
please wait ...