Multiple Inheritance of Classes

Denis Koroskin 2korden at gmail.com
Thu Aug 14 05:42:40 PDT 2008


On Thu, 14 Aug 2008 16:09:57 +0400, Manfred_Nowak <svv1999 at hotmail.com>  
wrote:

> superdan wrote:
>
>> no idea why walt chose to disallow that.
>
> It may cause some problems:
> interface Customer
> {
>     string ssn();
>     string name();
>     string uniqueName() { return name ~ "(ssn: " ~ ssn ~ ")"; }
> }
>
> interface SpecialCustomer
> {
>     string ssn();
>     string name();
>     string uniqueName() { return name ~ "!!!!!(ssn: " ~ ssn ~ ")"; }
> }
>
> class D: Costumer, SpecialCostumer{ string ssn="", name="";}
>
>
>
> 1) What is the result of `(new D).uniqueName'  ?
> 2) Is the locality of code controlable?
> 3) ...
>
> -manfred

I think the class should become abstract unless it reimplements the  
uniqueName(), ssn() and name() methods. Problem is, ssn and name variables  
are in a conflicting state with the methods of the same name.

class D : class D: Costumer, SpecialCostumer {
     string ssn="", name="";
}

class E : D
{
     string ssn() { return super.ssn; }
     string name() { return super.name; }
     string uniqueName() { return Costumer.uniqueName() }
}



More information about the Digitalmars-d mailing list