"extending" existed class

Jarrett Billingsley kb3ctd2 at yahoo.com
Wed Oct 18 12:31:19 PDT 2006


"novice2" <sorry at noem.ail> wrote in message 
news:eh5hi3$2v32$1 at digitaldaemon.com...
> Ah.. Only for arrays :(
> Thank you for information.
>
> Sorry for dumb question, but are there any
> other ways to "extend" existed classes?
> Inheritance only?

Yep.  Some people have proposed something found in C#, where you can add 
methods to classes from outside the class, like:

class C
{
    int method()
    {
        return 10;
    }
}

int C.method2()
{
    return 20;
}

C c = new C();
c.method();
c.method2();

But this is not possible in D. 





More information about the Digitalmars-d-learn mailing list