Easy way to implement interface properties?

Namespace rswhite4 at googlemail.com
Tue Dec 31 16:53:52 PST 2013


On Wednesday, 1 January 2014 at 00:48:13 UTC, Frustrated wrote:
> Is there an easy way to implement properties of an interface 
> within a class instead of having to duplicate almost the exact 
> same code with generic properties?
>
> interface A
> {
>     @property int data() { return m_data; } // read property
>   @property int data(int value) { return m_data = value; } // 
> write property
>
> }

Without access to some members, yes: make the methods final.
With (as in your case): Only with an abstract class or with a 
mixin template.


More information about the Digitalmars-d-learn mailing list