why can't structs implement interfaces?

Lutger lutger.blijdestijn at gmail.com
Tue Nov 24 14:47:11 PST 2009


Saaa wrote:

> struct S : Pos {}
> Why is this not possible?
> 
> 

Because structs are meant to be value types and thus do not implement 
dynamic polymorphism, which is what interfaces are used for.  It is not 
necessary though, classes in C++ are almost the same as structs for example, 
but there are problems with that design.

 


More information about the Digitalmars-d-learn mailing list