Need encouraging...

Steven Schveighoffer schveiguy at yahoo.com
Thu Oct 4 08:54:16 PDT 2007


"Arlen Albert Keshabyan" wrote
> Steven Schveighoffer Wrote:
>
>> Do the listener types have any implementation?  If not, you can code them 
>> as
>> interfaces, and you don't need multiple inheritance.  The JUCE project 
>> may
>> have used multiple inheritance to emulate interfaces because interfaces 
>> are
>> not available with C++.
>>
>>
>
> That's not true! C++ has interfaces! Even more, abstract C++ classes can 
> be used as interfaces, as abstract classes itself and as interfaces with 
> partially implemented factions and data.

No, C++ does not have interfaces.  It has abstract classes.  Interfaces are 
not allowed to have implementations.  C++ can *mimic* interfaces with 
abstract classes that have no implementation, but the concept of an 
interface is not a language feature.  What I meant by my comment is that 
perhaps JUCE used abstract classes/multiple inheritance to mimic interfaces 
because interfaces are not supported, but I see from your comment below that 
they have some implementation.

> Well yes, some JUCE listener types have some implementation. Even more, 
> programmers encouraged to write their own custom listeners to their own 
> components and there they can re-implement and reuse derived members...

That would pose a problem.  You can somewhat mimic multiple inheritance by 
using inner classes, but generally, doing so does not directly map from C++. 
For an example of how this can work, see my post replying to Olifant on 
"Multiple Inheritance".

-Steve 





More information about the Digitalmars-d mailing list