What is the Utility of Parent Class Method Hiding in Inheritance?
Vijay Nayar
madric at gmail.com
Wed Jan 16 17:23:22 UTC 2019
On Wednesday, 16 January 2019 at 17:01:06 UTC, Steven
Schveighoffer wrote:
> On 1/14/19 2:30 PM, Neia Neutuladh wrote:
>> On Mon, 14 Jan 2019 09:10:39 +0000, Vijay Nayar wrote:
>>> a.foo(1); // issues runtime error (instead of calling
>>> A.foo(int))
>>
>> Calling the function doesn't issue any sort of error.
>> Overriding one
>> overload without overloading or explicitly aliasing in the
>> rest issues a
>> compile-time error.
>>
>> If you got a runtime error instead, please create a bug report.
>>
>>> I ran into this the other day, where I had a function of the
>>> same name
>>> in a child class, and found that all functions in the parent
>>> of the same
>>> name now became hidden, unless I add an alias statement.
>>
>> If the functions from the parent class are hidden but your
>> code compiles,
>> please create a bug report.
>>
>
> Well, for sure, the documentation needs to be updated!
>
> It was 2.068 that removed the HiddenFuncError, and made this a
> compile error instead. If your compiler is that or newer,
> definitely file a bug report.
>
> -Steve
It's a compile error, and it says that one should use alias as
well. I was just surprised and I hadn't thought of why this
alias would be needed. Based on the recommendation I found the
language documentation, but there was no link to the article
explaining the rationale. But I'm glad I read that article, it
makes a lot more sense now.
More information about the Digitalmars-d-learn
mailing list