struct inheritance need?

Kagamin spam at here.lot
Thu Dec 18 04:24:34 PST 2008


Weed Wrote:

> Kagamin ÐÉÛÅÔ:
> > Weed Wrote:
> > 
> >>> Global variables are static members of module, wich is similar to
> >>> class and also has static constructor.
> >> So what?
> > 
> > So your problem is solved.
> 
> If everything was so simple! :)
> 
> Once again: the static constructor of class NOT constructs an object.

Static constructor can execute any valid D statements including construction of objects.
This works:
---
import std.stdio;

class Matrix
{
	int i;

	this(int j)
	{
		i=j;
	}
}

Matrix m;

static this()
{
	m=new Matrix(7);
}

void main()
{
    writeln(m.i);
}
---


More information about the Digitalmars-d-learn mailing list