Você está na página 1de 2

The class that is inherited is called the base class and the class that does the

Inheritance is called the derived class.

Inheritance2.jpgHow to use Inheritance?

So the final question is, how to use Inheritance. First note that a class can be
derived from more than one class or interface.

The class that is inherited is called the base class and the class that does the
Inheritance is called the derived class.

As I explained above, the main purpose of inheritance is to reuse existing code.


Now think about programming, you can do the same thing with code. You can use the
existing code feature in your own code. If you want to add some members of the old
class in your new class then you can do that with inheritance. As you know,
inheritance is an important concept of OOP. Do not take it lightly. If you
understand Inheritance very well then you can be a good programmer. You can say
that it is a pillar of OOP. If it is strong then OOP is automatically strong. There
are 4 pillars of OOP. They are:

Inheritance
Abstraction
Polymorphism
Encapsulation
In this article I explained Inheritance. In the future I will explain the remaining
three Pillars. So I hope you now understand why we use Inheritance. Now for the
last question.

Inheritance2.jpgHow to use Inheritanc

let us suppose that there is a class named A. You want to inherit the members of
Class A in Class B. Then Class A is called the base class and Class B is called the
derived class.

The syntax to inherit the class is:

<access-specifier> class <base_class>


{

So the final question is, how to use Inheritance. First note that a class can be
derived from more than one class or interface.

The class that is inherited is called the base class and the class that does the
Inheritance is called the derived class.

Inheritance2.jpgHow to use Inheritance?

So the final question is, how to use Inheritance. First note that a class can be
derived from more than one class or interface.

The class that is inherited is called the base class and the class that does the
Inheritance is called the derived class.

As I explained above, the main purpose of inheritance is to reuse existing code.


Now think about programming, you can do the same thing with code. You can use the
existing code feature in your own code. If you want to add some members of the old
class in your new class then you can do that with inheritance. As you know,
inheritance is an important concept of OOP. Do not take it lightly. If you
understand Inheritance very well then you can be a good programmer. You can say
that it is a pillar of OOP. If it is strong then OOP is automatically strong. There
are 4 pillars of OOP. They are:

Inheritance
Abstraction
Polymorphism
Encapsulation
In this article I explained Inheritance. In the future I will explain the remaining
three Pillars. So I hope you now understand why we use Inheritance. Now for the
last question.

Inheritance2.jpgHow to use Inheritance?

So the final question is, how to use Inheritance. First note that a class can be
derived from more than one class or interface.

The class that is inherited is called the base class and the class that does the
Inheritance is called the derived class.

For example,

let us suppose that there is a class named A. You want to inherit the members of
Class A in Class B. Then Class A is called the base class and Class B is called the
derived class.

The syntax to inherit the class is:

<access-specifier> class <base_class>


{
...
}
class <derived_class> : <base_class>
{
...
}

Você também pode gostar