interface and class inheritance

Oleg B code.viator at gmail.com
Thu Nov 14 13:20:56 PST 2013


[code]
import std.stdio;

interface A { void funcA(); }
class B { final void funcA() { writeln( "B.funcA()" ); } }

class C: B, A { }

void main()
{
     auto c = new C;
     c.funcA();
}
[code/]

$ dmd -run interface.d
interface.d(6): Error: class interface.C interface function 'void 
funcA()' is not implemented

if swap A and B
[code]
class C: A, B { }
[code/]

$ dmd -run interface.d
interface.d(6): Error: class interface.C base type must be 
interface, not interface.B

how to workaround this without change in class B and interface A?


More information about the Digitalmars-d-learn mailing list