Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Let's Go! Super D Wish Dream Taimu Desu~

Name: Anonymous 2012-02-07 11:49

Didn't see a D thread. Let's get this shit going!

Using a template mixin to simulate multiple inheritance:

template mixin Parent1
{
    public
    {
        void writeMsg1()
        {
            writeln("Hey proggit!");
        }
    }
}

template mixin Parent2
{
    public
    {
        void writeMsg2()
        {
            writeln("Why haven't you learned D yet?");
        }
    }
}

class Child
{
    mixin parent1;
    mixin parent2;
}

At compile time, Child is expand to this:
class Child
{
    public
    {
        void writeMsg1()
        {
            writeln("Hey proggit!");
        }
    }

    public
    {
        void writeMsg1()
        {
            writeln("Why haven't you learned D yet?");
        }
    }
}

You can now create an instance of Child and call it's two member functions, writeMsg1 and writeMsg2. It's that simple!

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List