Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 29, 2006 05:05 AM by biswajitdash
May 24, 2006 05:46 PM|LINK
I am trying to understand the advantages of using interfaces. I found this example on the internet:
Function Clone() As Object Implements ICloneable.Clone
which creates a shallow copy of an object. I tried it out and it works fine. Now it tried the same thing without the "implements icloneable" command and withouth the "implements icloneable.clone" definition for the method. It works in the same exact way.
Why, then, use an interface? The only advantage I see is forcing object implementation to use a specific number and type of interfaces but that doesnt really help me with code reuse... what am I missing?
May 24, 2006 06:07 PM|LINK
May 24, 2006 06:30 PM|LINK
But.... I could do the same thing without the interface..... If I am sure that both classes implement the Start() and MoveBackward() methods I can call them directly without using any interface......
I still cannot see why or how can I benefit from implementing a common interface.....
May 24, 2006 06:35 PM|LINK
May 24, 2006 06:47 PM|LINK
May 24, 2006 07:13 PM|LINK
May 24, 2006 07:20 PM|LINK
May 24, 2006 08:04 PM|LINK
Sounds reasonable... is there any other major advantage to interfaces that you can think about?
The most important is multiple inheritance, you can get only single inheritance from classes but an interface gives you multiple inheritance.
May 24, 2006 08:46 PM|LINK
May 24, 2006 10:04 PM|LINK