Default constructor for structs

rouge rouge at gmail.com
Sat Aug 7 09:23:37 PDT 2010


Hi, I'm a newbie, hope the attached example works for you.

Peter Alexander wrote:
> Since default constructors for structs are not allowed, how do I go 
> about making all the elements of this Matrix struct default to zero? 
> (floats default to nan by default).
> 
> struct Matrix(int M, int N)
> {
>     float[M][N] elements;
> }
> 
> Matrix(3, 3) m;
> assert(m[0][0] == 0);
> 
> ?
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: sctor.d
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20100808/5bac5090/attachment.ksh>


More information about the Digitalmars-d-learn mailing list