struct inheritance need?

Weed resume755 at mail.ru
Tue Dec 23 03:37:40 PST 2008


Kagamin пишет:
> Weed Wrote:
> 
>>> I'd prefer run-time checks, though
>>> templates can be used for sure.
>> This problem would help solve the availability of inheritance for 
>> structs or compile-time creation of class instances.
> 
> And I see no problem. Absence of compile-time object creation doesn't prevent you from using templates.

The problem is not in use templates.

Templates are implementing some of the functionality of 2 types of 
structures matrices (normal and dynamic). But the structures do not 
inherit, then to add functionality matrix to other entities ( "pixel", 
"image" etc) sites will have their list in a template return type.

For example:
http://www.dsource.org/projects/openmeshd/browser/trunk/LinAlg/linalg/MatrixT.d

see template MultReturnType(ArgT)

It contain list of all types (MatrixT and VectorT) for return. Will it 
add types of "image" and "pixel" and still others if needed. This is as 
good as manually implement a new object model.

It is not necessary to suggest to wrap up "pixel" in a class - then it 
too cannot be initialized in a compile time.


More information about the Digitalmars-d-learn mailing list