Compile-time reference type objects construction (Was - Re: struct
Kagamin
spam at here.lot
Mon Dec 22 04:05:34 PST 2008
Denis Koroskin Wrote:
> class Widget
> {
> WidgetFactory* factory = &defaultFactory;
> }
>
> void main()
> {
> Widget w = new Widget();
> writefln(w.factory.someParameterValue); // prints 14
> }
You initialize member field here. It's usually done in instance constructor.
class Widget
{
WidgetFactory factory;
this(){ factory = defaultFactory; }
}
More information about the Digitalmars-d-learn
mailing list