Need encouraging...
Don Clugston
dac at nospam.com.au
Fri Oct 5 02:48:33 PDT 2007
Janice Caron wrote:
> On 10/5/07, James Dennett <jdennett at acm.org> wrote:
>>> C++ can *mimic* interfaces with
>>> abstract classes that have no implementation,
>
> It's the other way round. Interfaces mimic abstract classes - but
> incompletely. Interfaces allow a workaround for the lack of multiple
> inheritance, but C++ classes are without doubt the more fully featured
> of the two.
In theory multiple inheritance is a superset of interfaces. However, in practice
there is an optimization penalty when using multiple inheritance which is not
present with interfaces.
Hence, for example, MSVC adds __declspec(novtable) to turn an ABC into a true
interface.
> Saying that C++ does not have D interfaces merely because the compiler
> does not complain when you provide implementations, is like saying D
> does not support C structs because the compiler does not complain when
> you provide member functions.
>
> Saying that C++ mimics interfaces because C++ can do more, is like
> saying D templates *mimic* C++ templates, because D can do more.
>
> See, what you've done there is you've taken a limitation and called it
> a feature.
I think that C++ does make the concept of interfaces difficult to recognize.
"Since people could put data in the base classes, they sort of felt obliged to
do so. " -- Bjarne Stroustrup.
http://www.artima.com/intv/modern.html
More information about the Digitalmars-d
mailing list