Any way to override base type with dervived in derived type

IntegratedDimensions IntegratedDimensions at gmail.com
Fri May 25 18:36:02 UTC 2018


On Friday, 25 May 2018 at 10:45:23 UTC, Steven Schveighoffer 
wrote:
> On 5/24/18 4:24 PM, IntegratedDimensions wrote:
>
>> What I'd like to do is
>> 
>> class C : A
>> {
>>     private override @property TT t() { return cast(TT)(_t); } 
>> // null check if necessary
>>     // Stuff below uses t which is now a TT
>>     ...
>> }
>
> It should work, you are allowed covariant overloads. However, 
> private functions are not virtual, you need to make them at 
> least protected.
>
> -Steve

Wow, I didn't expect that! Thanks, exactly what I needed.

Unfortunately property setters seem to be broken.

https://dpaste.dzfl.pl/24ce8c7e0681

Seems this is a bug though that has been fix as it only happens 
on certain the older compilers. I had to downgrade because in the 
latest I get a lot of link errors ;/




More information about the Digitalmars-d-learn mailing list