G
Guest
I was trying to break some polymorphism, expecting it not to work, but I'm a
curious sort.
I was seeing what happens when a derived class tries to hide an inherited
method with a private new method, expecting an error or warning; I got
neither with the result that the inherited method does _not_ get hidden (i.e.
not possibe to break polymorphism/inheritance this way, yay!)
My question then is, why is there no warning that the code may not work the
way the writer expects? Is it simply because the _new_ keyword turns it off?
Without the _new_ keyword, the warning about hiding fires, but this is a case
where no hiding will happen anyway, because the private method _does_not_
hide the inherited method.
curious sort.
I was seeing what happens when a derived class tries to hide an inherited
method with a private new method, expecting an error or warning; I got
neither with the result that the inherited method does _not_ get hidden (i.e.
not possibe to break polymorphism/inheritance this way, yay!)
My question then is, why is there no warning that the code may not work the
way the writer expects? Is it simply because the _new_ keyword turns it off?
Without the _new_ keyword, the warning about hiding fires, but this is a case
where no hiding will happen anyway, because the private method _does_not_
hide the inherited method.