Override @property

Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed May 10 09:52:19 PDT 2017


On Wednesday, 10 May 2017 at 16:40:09 UTC, Aldo wrote:
> class PictureBox : Control
> {
> 	@property
> 	public override void texture(Texture value)
> 	{
> 		writeln("override");
> 		this.m_texture = value;
> 	}
> }
>
> Error: function f340.PictureBox.texture (Texture value) is not 
> callable using argument types ()


Yes, that's normal. If you override one function in a child 
class, you need to explicitly bring in the other overrides by 
adding

alias texture = Control.texture; // I think you can also use 
`super.texture`

in the class with the new override. That tells it to look up the 
name from the parent as well.

The rationale is here: http://dlang.org/hijack.html

It isn't just properties btw, any case of overloads is subject to 
the same rule.


More information about the Digitalmars-d-learn mailing list