| | |
oops Inheritence
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
>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.
>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.
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)
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)
![]() |
Similar Threads
- java-fresher (Java)
Other Threads in the C++ Forum
- Previous Thread: setting commas
- Next Thread: Problem in compiler and Run button , missing file
| Thread Tools | Search this Thread |
api array arrays beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion convert count data database delete desktop developer directshow dll dynamic dynamiccharacterarray email encryption error file forms fstream function functions game getline google graph homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates test text tree unix url vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






