Why can't I inherit (extend) structs?

rm roel.mathys at gmail.com
Wed Oct 11 09:34:51 PDT 2006


Jarrett Billingsley wrote:
> 
> Then you have to make sure to mix in the correct base structs in the correct 
> order

why do you say correct order?
when mixin in 2 structs with the same-named member,
the first time I reference that member in the new struct,
the thing won't compile any more?

rm
=========================================================
private import std.stdio;

template XT()
{
	struct
	{
		int x;
	}
}

template YT()
{
	struct
	{
		int x;
	}
}

struct X
{
	mixin XT;
}

struct Z
{
	mixin XT;
	mixin YT;
	int z;
}

void main()
{
	X x;
	x.x = 5;
	writefln(x.x);
	Z z;
	z.x = 1;
	z.z = 2;
	writefln(z.x,' ',z.z);
}



More information about the Digitalmars-d-learn mailing list