2 Years
Discussion Span
Last Post by Loosipher

inheritance is a Is A relation Ship between Classes
Polymorphism means many forms
or single interface multiple implimentations
is correct???


tell me some more differrence

Edited by rizwan anjum: question mark not include


In OOP terminology, polymorphism is the ability for sub-classes to extend or even change the behavior they inherit from their parent classes. For example, if you have a class Animal, which has an abstract method named speak():

public abstract class Animal {
    public abstract void speak();

Then you can instantiate the behavior in the sub-classes Dog and Cat thusly:

public class Dog: Animal {
    public override void speak() {

public class Cat: Animal {
    public override void speak() {

If you then create an Animal variable, and assign it a Dog() object, the object will respond to the speak() method with "Woof".


what's difference b/t polymorphism andinheritance

Polymorphism is an optional feature of inheritance. Your question suggests that you think they're independent, which they're not. Without inheritance (or a significant amount of hackish workarounds), polymorphism doesn't occur.

That's assuming of course that we're talking about polymorphism through virtual member functions rather than polymorphism through templating or overloading. I think that's a safe assumption though, as most people mean polymorphism through inheritance when they say "polymorphism".


It may also be useful to point out that polymorphism is a characteristic of your design, whereas inheritance is a feature of your development system.
For exammple when in winforms, you drag a button and a texbox on your form, you experience polymorphism. This is made possible because both textboxes and buttons inherit from controls. In fact what achieves polymorphism is the fact that different objects implement a common interface. Inheritance is one of the features that provide this, but it's not the only one, and what's more, inheritance in itself does not warrant polymorphism.


In c# polymorphism, which means many forms.
it contains overloading and overriding.
overloading in the sence complile time polymorphisim

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.