Creating and implementing an interface
For many developers, interfaces are confusing and their purpose not clearly understood. Interfaces are actually quite easy to get to grips with once you understand the concept that defines an interface.
Interfaces act like verbs. So, for example, if we had to create two classes called
Tiger that derive from the
Cat abstract class, the interface would describe some sort of action. Lions and tigers can roar (but not purr). We can then create an interface called
IRoarable. If we had to derive a class called
Cheetah from our abstract class
Cat, we would not be able to use the
IRoarable interface, because cheetahs purr. We would need to create an
Creating an interface is ...