I was wondering why C # does not allow the private virtual function and comes across aptly named Why are private virtual methods illegal in C #?
In the accepted answer, Eric Lippert (who probably knows what he is talking about ...) said:
If you want to limit the ability to override a method in non-nested derived classes, you can do this by limiting the ability of non-nested classes to infer from the base class;
In C ++, private: virtual makes sense because it means: "I want the classes received from me to redefine the functionality of this function, but they should not call it directly," in other words, private controls that can call a function and does not affect who can override it.
I understand that since only derived classes can be overridden in the first place, and since C # forbids private virtual functions, this question may be pointless if there are other scenarios in which the level of protection of the function can affect that can override it ( protected internal possible )?
c ++ private c # language-design
Motti
source share