Prepare for your Next Interview
|
Welcome to the Geeks Talk forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
This is a discussion on inheritance within the C# forums, part of the Software Development category; explain about inheritance...
|
|||||||
|
|||
|
inheritance
explain about inheritance
|
| The Following User Says Thank You to sumad For This Useful Post: | ||
| Sponsored Links |
|
|||
|
Re: inheritance
Inheritance lets you reuse the state and behaviour of a object to create a new object;Inherit from a class whose state and behaviour u need to extend and thats it.
Advantages: ->Code Reuse. ->Implement Polymorphic behaviour. |
|
|||
|
Re: inheritance
Inheritance is reusing the properties and methods of a parent class into a sub class.
Eg. Following are the 2 classes that are designed without following the inheritance concepts. Class: means-of-transport Properties: wheels, seats, body-type, runs-on Methods: start, run, stop Class: car Properties: name, wheels, seats, body-type, runs-on, manufacturer, fuel-type Methods: start, run-forward, run-backward, stop As we see there is duplication of data. To avoid duplication, the class ‘car’ can be declared as sub class of the class ‘means-of-transport’ inheriting some of its properties as shown below. Class: means-of-transport Properties: wheels, seats, body-type, runs-on Methods: start, run, stop Class: car INHERITS means-of transport Properties: name, manufacturer, fuel-type Methods: run-forward, run-backward Assumptions: some means of transport may not run backwards, but car can. Every means of transport will have some number of wheels, some number of seats, some body type and runs on something or the other including a car. Every means of transport starts and stops.
__________________
Lack of WILL POWER has caused more failure than lack of INTELLIGENCE or ABILITY. -sutnarcha- |
|
|||
|
Re: inheritance
Here is good link, which answers your question with gud ex :-)
http://www.csharp-station.com/Tutorials/Lesson08.aspx |
|
|||
|
Re: inheritance
Inheritance is a way of reusing the method, properties etc. This allows you to define class for very specific reason and inherit rest of the methods and properties from base class (which again is specifi for its own reason). This also gives you Hierarchical approach to you project
|
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Types of Inheritance | scott | OOPS | 26 | 08-09-2009 03:01 AM |
| multiple inheritance in java... | psuresh1982 | Java | 20 | 07-23-2007 02:33 PM |
| multiple inheritance.... | psuresh1982 | Java | 2 | 01-22-2007 12:57 AM |