oops Inheritence

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Aug 2006
Posts: 319
Reputation: Luckychap is on a distinguished road 
Solved Threads: 42
Luckychap's Avatar
Luckychap Luckychap is offline Offline
Posting Whiz

oops Inheritence

 
0
  #1
Apr 6th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,660
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 723
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: oops Inheritence

 
0
  #2
Apr 6th, 2008
>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.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 34
Reputation: chiwawa10 is an unknown quantity at this point 
Solved Threads: 5
chiwawa10's Avatar
chiwawa10 chiwawa10 is offline Offline
Light Poster

Re: oops Inheritence

 
0
  #3
Apr 6th, 2008
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)
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC