Why isn't that a compilation error? - define a variable in a subclass with the same name of a superclass method

Steven Schveighoffer schveiguy at gmail.com
Thu Nov 10 14:30:30 UTC 2022


On 11/10/22 8:36 AM, Hipreme wrote:

> It basically ignores the old method to just use the new variable.
> 
> If I try:
> ```d
> t.position([1,2,3]);
> ```
> I get the error: onlineapp.d(26): Error: function expected before `()`, 
> not `t.position` of type `float[3]`
> 
> There's something really misleading

When you derive a type, and override a name, the old name is masked or 
hidden. You can alias the original name in, but I don't think it would 
work for overloading a field with a function.

-Steve


More information about the Digitalmars-d mailing list