const "override" and interfaces

gzp galap at freemail.hu
Fri Oct 9 14:23:04 PDT 2009


It has some bug for sure, or the interface should be reconsidered:

interface I1 { int foo(); }
interface I2 { const int  foo(); }

class C1 : I2,I1{
 int foo() { return 0; }
 const int foo() { return 1; }
}

class C2 : I1,I2{
 int foo() { return 0; }
 const int foo() { return 1; }
}

C1 won't compile, while C2 compiles. 
For me it is quite strange why are the 2 cases distinct. The order of inheritance should be identical and if the interfaces defines the same members(functions), than only the same implementation should apply for both interfaces.ex:
interface A {  void foo() }
interface B { void foo() }
class C { void foo() {...}  // implementation of both interfaces }
(I think in Java it works this way)



Tanks,



More information about the Digitalmars-d mailing list