Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

15
  • 1
    Never heard of polymorphy, you mean polymorphism? Commented Sep 14, 2011 at 14:13
  • 1
    that being said, if microsoft allowed multiple inheritance in the first place, there would have been no reason for existence of interfaces Commented Sep 14, 2011 at 14:15
  • 11
    @Pankaj Upadhyay: Multiple inheritance and interfaces are two different pairs of shoes. What if you need an interface of two unrelated classes with different behaviour? You can't solve that by multiple inheritance. You HAVE TO implement it separately anyway. And then you'll need something to describe the interface in order to provide polymorphic behaviour. Multiple inheritance is a blind alley to walk down in many cases, and it's too easy to shoot yourself in the foot sooner or later. Commented Sep 14, 2011 at 14:17
  • 1
    Lets simplify. If my interface implements two functions Display and Comment, and I have a class which implements them. Then why not I remove the interface and use the functions directly. What i am saying is that they are merely providing you the names of the functions that are needed to be implemented. If one can remember those functions then why create an interface Commented Sep 14, 2011 at 14:25
  • 9
    @Pankaj, if that is all that you need the interface for, then don't use it. YOu use an interface when you have a program that wants to be ignorant of every aspect of the class and access it by its base Type, i.e. the interface. They don't need to know any of the subclasses, just that it is of the type of the interface. As such, you can then call the implemented method of the sub-class through the reference to the object's interface. This is basic inheritance and design stuff. Without it, you might as well use C. Even if you don't explicitly use it, the framework would not work without it. Commented Sep 14, 2011 at 14:33