override and package
Maxim Fomin
maxim at maxim-fomin.ru
Thu Sep 12 09:16:13 PDT 2013
On Thursday, 12 September 2013 at 11:29:22 UTC, Jacob Carlborg
wrote:
> On 2013-09-12 11:28, Namespace wrote:
>
>> But if I try to write 'override' before [1], I get this error
>> message:
>> Error: function T4._apply cannot override a non-virtual
>> function
>>
>> This seems inconsistent. I really overwrite the method, and
>> then I put
>> it in a package label.
>
> I think the error message is pretty clear. You cannot override
> a function that isn't virtual. Private and package methods are
> not virtual.
Actually error message is misleading - it complains as T1._apply
would be non-virtual function which is wrong, it is one. The
problem is not in case of overriding non-virtual function but in
attempt to override virtual function (private) by non-virtual one
(package). I think error mesage should be something like:
"Error: function T4._apply is non-virtual function and cannot
ovverride virtual function T1._apply"
More information about the Digitalmars-d-learn
mailing list