Geeks Talk

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.

inheritance

This is a discussion on inheritance within the C# forums, part of the Software Development category; explain about inheritance...

Go Back   Geeks Talk > Software Development > C#
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read
  #1 (permalink)  
Old 04-16-2007
Junior Member
 
Join Date: Apr 2007
Location: hyderabad
Posts: 1
Thanks: 0
Thanked 1 Time in 1 Post
sumad is on a distinguished road
inheritance

explain about inheritance
Reply With Quote
The Following User Says Thank You to sumad For This Useful Post:
Sponsored Links
  #2 (permalink)  
Old 04-25-2007
Junior Member
 
Join Date: Apr 2007
Location: Hyderabad
Posts: 16
Thanks: 2
Thanked 1 Time in 1 Post
saswata.purkayastha is on a distinguished road
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.
Reply With Quote
  #3 (permalink)  
Old 04-25-2007
Expert Member
 
Join Date: Nov 2006
Location: Hyd-IND
Posts: 528
Thanks: 1
Thanked 63 Times in 50 Posts
sutnarcha is on a distinguished road
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-
Reply With Quote
  #4 (permalink)  
Old 04-25-2007
Contributing Member
 
Join Date: Mar 2007
Posts: 43
Thanks: 1
Thanked 2 Times in 2 Posts
varmakub is on a distinguished road
Re: inheritance

Here is good link, which answers your question with gud ex :-)
http://www.csharp-station.com/Tutorials/Lesson08.aspx
Reply With Quote
  #5 (permalink)  
Old 06-06-2007
Junior Member
 
Join Date: Feb 2007
Location: Bangalore
Posts: 17
Thanks: 0
Thanked 2 Times in 2 Posts
jbanx is on a distinguished road
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
Reply With Quote
Reply

  Geeks Talk > Software Development > C#

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


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


All times are GMT -4. The time now is 06:50 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved