What
is an Interface?
In
summary the Interface separates the implementation and defines the
structure, and this concept is very useful in cases where you need
the implementation to be interchangeable. Apart from that an
interface is very useful when the implementation changes frequently.
Some say you should define all classes in terms of interfaces, but I
think recommendation seems a bit extreme.
Interface
can be used to define a generic template and then one or more
abstract classes to define partial implementations of the interface.
Interfaces just specify the method declaration (implicitly public and
abstract) and can contain properties (which are also implicitly
public and abstract). Interface definition begins with the keyword
interface. An interface like that of an abstract class cannot be
instantiated.
If
a class that implements an interface does not define all the methods
of the interface, then it must be declared abstract and the method
definitions must be provided by the subclass that extends the
abstract class. In addition to this an interfaces can inherit other
interfaces.
any one having the example in c++, java or any object oriented programming language please comment
No comments:
Post a Comment