Hi guys,
I need to understand the concept of inheritance in Oops. Can any one explain with real life example the use of inheritence to enhance a super class. It will be very helfull to me if you can explain me the use of inheritence to build a simple car.

Thanks

>I need to understand the concept of inheritance in Oops.
>Can any one explain with real life example the use of inheritence to enhance a super class.
>It will be very helfull to me if you can explain me the use of inheritence to build a simple car.
It's actually funny how you went from a very broad question down to a very specific (somewhat unrelated) question in three sentences. Anyway:

>I need to understand the concept of inheritance in Oops.
Inheritance is nothing more than programming by extension. You take advantage of existing code by making it your own and then extending it with customizations.

>Can any one explain with real life example the use of inheritence to enhance a super class.
Okay, let's say you have a binary search tree class. Rather than re-implement all of the class framework and logistics for your new red black search tree, you can inherit the binary search tree class, re-implement only the parts that are different, and save yourself a lot of work. Also, interface compatibility falls out of this. You use the red black tree class just like the binary search tree class because they use the same interface.

>It will be very helfull to me if you can explain me the use of inheritence to build a simple car.
I'm not sure I would use inheritance to model a car.

Here's a simple example of OOP in real life (building of a car). Before that, I would like to stress that this example is not complete and only explained at the overview level. Here goes:

A car has windows. So, you might want to declare a glass class which is a general (parent) class. The child (class that inherits) can be defined to be side window class and windshield class.

(single inheritance)
----------------------
glass (parent)
--> windows (child)
--> windshield (child)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.