cannot I override and mark it as private?

Imperatorn johan_forsberg_86 at hotmail.com
Wed May 12 20:56:54 UTC 2021


On Wednesday, 12 May 2021 at 19:35:31 UTC, Jack wrote:
> I'd to change the visibility of a method overrided from public 
> to private but it doesn't work tho to protected it does. Why is 
> that?
>
> give:
>
> ```d
> class A
> {
>     void f() { }
> }
> ```
>
> this is ok:
>
> ```d
> class B : A
> {
>     protected override void f() { }
> }
> ```
>
> this is not:
>
> ```d
> class B : A
> {
>     private override void f() { }
> }
> ```
>
> Why is that? why must I leave it accessible somehow (even if 
> it's protected) to all derived class of my derived class?

Can you begin protected instead? 🤔


More information about the Digitalmars-d-learn mailing list