Does this bother me, please tell me the behavior of this?
The announcement of a new member hides the inherited member only within the scope of the new member. Copy
**class Base
{
public static void F() {}
}
class Derived: Base
{
new private static void F() {}
}
class MoreDerived: Derived
{
static void G() { F(); }
}**
In the above example, declaring an F in Derived hides an F that was inherited from Base, but since the new F in Derived has private access, its scope does not extend to MoreDerived. So the call to F () in MoreDerived.G is valid and will call Base.F.
I don’t understand how he static void G() { F(); }can access the method of the base class f, when he can access all the methods of his immediate superclass, and the superclass hides the method f of the base class
source
share