struct inheritance need?

Denis Koroskin 2korden at gmail.com
Sat Dec 20 05:58:49 PST 2008


On Sat, 20 Dec 2008 16:46:44 +0300, Christopher Wright  
<dhasenan at gmail.com> wrote:

> Sergey Gromov wrote:
>> Thu, 18 Dec 2008 18:36:07 -0500, Christopher Wright wrote:
>>
>>> Weed wrote:
>>>> Compile-time creation an object of class or (most likely wrong)  
>>>> struct inheritance.
>>>>
>>>> I have prepared a distinct feature request and send it later
>>> You aren't providing a use case, though. Why not show an example  
>>> (actual code) of what you would do if you had this ability?
>>  static invariant Identity = new Matrix([[1,0,0], [0,1,0], [0,0,1]]);
>
> Okay, do you want to access that matrix in a template? Is there a reason  
> it can't be a struct?

Let's say, there is an IMatrix interface and its implementations, such as  
SparseMatrix, RowMajor/ColumnMajorMatrix etc.

class IdentityMatrix : IMatrix
{
     public float at(int row, int col) { return (row == col) ? 1 : 0; }
}


More information about the Digitalmars-d-learn mailing list