Default constructor for structs
rouge
rouge at gmail.com
Sat Aug 7 09:31:09 PDT 2010
oops :p correction:
in template Zero
const float[M][N] ==> const T[M][N]
rouge wrote:
> 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);
>>
>> ?
More information about the Digitalmars-d-learn
mailing list