struct inheritance need?
Weed
resume755 at mail.ru
Tue Dec 16 04:24:59 PST 2008
Bill Baxter пишет:
> 2008/12/16 Weed <resume755 at mail.ru>:
>> I should explain why it's important for me:
>>
>> For example, I am making a matrix object(s)
>>
>> It should be:
>> - any size
>> - with ability of making matrix instance of a given size in compile time.
>> - ability of creating matrix instance in runtime.
>>
>> I have decided to make it struct because I need to create matrix
>> object in compile time. in real program I'll need matricies of
>> variable size and 3х1, 3х3, 6х6, 3х6 sizes (and may be other).
>>
>> I want to make matrix template and insert in it with mixin operator
>> several structures of different sizes (and this structs are not store his
>> dimensions in each instance, of course: variables width and height declared
>> as invariant). By doing this I'll get several different structures
>> (matrix_dynamic, matrix3x3, matrix6x6 etc)
>>
>> question is how those matricies can interoperate? They does not have
>> common parent (structures does not have inheritance) , so I can't
>> make common function for matricies of different sizes opAdd for
>> example, and have to do functions for all types of matricies.
>>
>> How should I implement such a class In D properly?
>> It possible in C++, but I like some of the language D
>>
>
> Here's one way:
> http://www.dsource.org/projects/openmeshd/browser/trunk/LinAlg/linalg/MatrixT.d
>
> --bb
necessarily need the ability to change the size of the matrix
together with a static matrix it can be done using two types of matrices
with a common parent.
More information about the Digitalmars-d-learn
mailing list