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.
隐藏和重写都重新定义继承的元素,但这两种方法之间有很大差异。
Shadowing and overriding are both used when a derived class inherits from a base class, and both redefine one declared element with another.
隐藏和重写都在派生类继承基类时使用,并且都是用另外的元素重定义一个已声明的元素。
Shadowing and overriding are both used when a derived class inherits from a base class, and both redefine one declared element with another.
隐藏和重写都在派生类继承基类时使用,并且都是用另外的元素重定义一个已声明的元素。
应用推荐