interfaces :-(
John Demme
me at teqdruid.com
Thu Mar 9 23:02:37 PST 2006
Walter Bright wrote:
>
> "John Demme" <me at teqdruid.com> wrote in message
> news:dqae9p$2bhh$1 at digitaldaemon.com...
>> I'm not sure that I fully understand covariance either, but that's the
>> word
>> that Walter used to say why the following doesn't work.
>>
>> interface I
>> {
>> I clone();
>> }
>>
>> class A: I
>> {
>> A clone();
>> }
>
> It'll work if you rewrite it as:
>
> interface I
> {
> Object clone();
> }
>
> class A: I
> {
> A clone();
> }
Fine. I'll give you a harder example:
interface Map (K,V)
{
V get (K k);
Map copy();
}
class HashMap (K,V): Map!(K,V)
{
V get(K k) {}
void rehash() {}
HashMap copy() {}
}
... And I've actually run into this problem.
~John Demme
More information about the Digitalmars-d-dtl
mailing list