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!
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!