Explicit Interface Implementation

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Feb 14 12:08:09 PST 2015


On 02/14/2015 09:19 AM, ref2401 wrote:
> Does D provide a way for explicit interface implementation?
> [C#] https://msdn.microsoft.com/en-us/library/ms173157.aspx

Apparently, yes:

interface A
{
     int foo();
}

interface B
{
     int foo();
}

class C : A, B
{
     int foo()
     {
         return 42;
     }
}

void main()
{
     auto c = new C();
     A a = c;
     B b = c;

     assert(a.foo() == 42);
     assert(b.foo() == 42);
}

Ali



More information about the Digitalmars-d-learn mailing list