interfaces :-(

Sean Fritz Sean_member at pathlink.com
Tue Jun 20 14:42:40 PDT 2006


In article <e798bq$2gmi$1 at digitaldaemon.com>, michal.minich at gmail.com says...
>
>This is now possible in D, here's example, hope it's helpful
>
>
>interface Comparable (T)
>{
>void compareTo(T o);
>}
>
>class A : Comparable!(A)
>{
>char[] textA;
>
>void compareTo(A o)
>{
>printf ("A.compareTo: " ~ o.textA ~\n);
>printf ( \n );
>}	
>}
>
>class B : A, Comparable!(B)
>{
>char[] textB;
>
>void compareTo(B o)
>{
>printf ("B.compareTo: " ~ o.textA ~\n);
>printf ("B.compareTo: " ~ o.textB ~\n);
>printf ( \n );
>}
>}
>
>
>void main ()
>{
>A a = new A();
>B b = new B();
>
>a.textA = "TextA in instance of A";
>
>b.textA = "TextA in instance of B";
>b.textB = "TextB in instance of B";
>
>a.compareTo(a);
>a.compareTo(b);
>b.compareTo(b);
>}

Does B also have a method/function (which do I use with D?) compareTo(A o)?

Sean





More information about the Digitalmars-d-dtl mailing list