reference to an interface
Jari-Matti Mäkelä
jmjmak at utu.fi.invalid
Tue Apr 11 12:43:50 PDT 2006
kris wrote:
> Frank Benoit wrote:
>> An interface is something like a promise. A class implementing an
>> interface promises to have all these methods. Your class C2 is
>> overriding the method from C1 that's all. Your two "help" methods are
>> not two different one, they are the same.
>>
>> C2 promises twice to implement a methods "void help();", inherants the
>> one from C1 and overrides it.
>
> That's a really good analogy/description ...
Indeed. But when will it promise to sort things too (== when will it
really treat instances of an interface as objects) ;)
#interface comparable {
# int opCmp(Object o);
#}
#
#class item : comparable {
# int opCmp(Object o) { return 1; }
#}
#
#void main() {
# comparable[] c; // compiler/lang spec "problem" here
# c ~= new item;
# c ~= new item;
# c ~= new item;
#
# c.sort; // segfaults here
#}
--
Jari-Matti
More information about the Digitalmars-d-learn
mailing list