@property and interfaces

bearophile bearophileHUGS at lycos.com
Tue Jun 29 05:22:27 PDT 2010


BLS:
> But this one NOT.
> 
> interface IBindingList {
> 		
> 	@property bool AllowEdit();
> 	@property bool AllowEdit(bool enable);
> }
> class A : IBindingList {
> 	private bool _allowEdit;
> 
> 	@property {
> 		bool AllowEdit() { return _allowEdit;	}
> 	}	
> }
> IMO this is bad design.
> bjoern


Is this good for you?

interface IBindingList {
    @property bool AllowEdit();
    @property bool AllowEdit(bool);
}

class A : IBindingList {
    bool _allowEdit;
    @property bool AllowEdit() { return _allowEdit; }
    @disable @property bool AllowEdit(bool) { return true; }
}

void main() {}

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list