interface reference not compatible to Object?
Alexander Panek
a.panek at brainsware.org
Sat Oct 21 04:20:57 PDT 2006
As already said in #d, this one compiles:
interface IObject {
void print();
char[] toString();
hash_t toHash();
int opCmp(Object o);
int opEquals(Object o);
}
interface I : IObject {
void func();
}
class C : I {
void func(){
}
}
void main(){
C c = new C;
c.toHash();
I i = c;
i.toHash();
}
..without given errors. Might be an option to add it into object.d or
such.
Best regards,
Alex
On Sat, 2006-10-21 at 11:44 +0200, Frank Benoit (keinfarbton) wrote:
> interface I{
> void func();
> }
> class C : I {
> void func(){
> }
> }
> void main(){
> C c = new C;
> c.toHash(); // from class Object
> I i = c;
> i.toHash(); // line 14
> }
> /////////////////////////////
> t.d(14): no property 'toHash' for type 't.I'
> t.d(14): function expected before (), not 1 of type int
>
>
> Is this the intended behaviour? If *every* object in D is a Object, then
> every interface reference refers to an Object also. This said, the above
> should compile?
More information about the Digitalmars-d
mailing list