无法在遮蔽项目的衍生类别内存取受遮蔽项目 (Shadowed Element),除非是从无法存取主导遮蔽项目 (Shadowing Element) 的类别内。例如,如果 Private 项目会遮蔽基底类别项目,则无权存取 Private 项目的程式码会改为存取基底类别项目。
基于20个网页-相关网页
If you shadow the same base class element with more than one element in your derived class, the shadowing elements become overloaded versions of that element.
如果用派生类中的多个元素隐藏同一个基类元素,隐藏元素将变为该元素的重载版本。
In such a case, shadowing is defeated and the compiler resolves any reference to the same element it would have if there had been no shadowing.
在这种情况下,隐藏就会失败,并且如果以前没有隐藏,编译器就会将任何引用解析为它包含的同一个元素。
Both shadowing and overriding redefine an inherited element, but there are significant differences between the two approaches.
隐藏和重写都重新定义继承的元素,但这两种方法之间有很大差异。
应用推荐