This page contains an archived post to the Design Forum (formerly called the Flexible Java Forum) made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
Posted by Atul Mathur on 15 Dec 1998, 3:06 PM
> If Interfaces are so useful in Java,
> why is it that you did not make use of pure virtual base classes in C++? Is there some difference between them which make the Java interface easier to use? Has Java, by disallowing multiple implementation inheritance, made you take the step of separating implementation from interface in a way you would not have done without being forced to? Also, if you now went back to C++ would you now make much more use of virtual
> base classes than you did before?
There are dozens of design patterns in the Gamma et al, which
make use of pure virtual base classes to great effect.
COM interfaces are just that: pure virtual base classes with
reference counting, QueryInterface and rules about them.
Unfortunately, using multiple inheritance for implementing
COM interfaces is just not practical. So it becomes a real
pain adding another COM interface to an ordinary C++ class,
unless you are using ATL, and playing the full COM game.