Abstract Classes vs Interfaces
Ary Borenszweig
ary at esperanto.org.ar
Thu Jul 8 04:59:08 PDT 2010
On 07/07/2010 06:24 PM, Justin Johansson wrote:
> Currently I'm struggling with unifying some C++ and Java code with
> the idea that I might eventually port it to D2.
>
> C++ people will know that their language supports abstract classes
> and multiple inheritance but not interfaces per se (although they
> can be hacked as abstract classes with implicit/trivial constructors).
>
> Java people will know that their language also supports abstract
> classes and interfaces though not multiple inheritance.
>
> In respect of the support of abstract classes, multiple inheritance
> and interfaces, both D1 and D2 are closer to Java than C++.
>
> May I please ask of this group their opinions as to the difference
> between abstract classes and interfaces from an axiomatic viewpoint.
>
> Is there a difference axiomatically, semantically or otherwise?
>
> Thanks in advance for all comments,
>
> Justin Johansson
Basically an interface is a contract: if a class implement that
interface then it provides all the methods described in the interface.
An abstract class just serves building common functionality for a set of
classes that will inherit from it. If an abstract class provides no
functionality at all then it might well be think of as an interface (it
should be replaced by an interface.)
From the other reply it seems that interfaces in D can have
final/static methods. That kind of goes against what I just said about
interfaces...
More information about the Digitalmars-d
mailing list