Re: Hiding inherited method



PIEBALD <PIEBALD@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
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.

Well, it hides it within that class - it just doesn't hide it for other
users of the class.

--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.



Relevant Pages

  • Re: Suduko solver demo
    ... form of the sudoku solver as downloaded. ... private List remainingCells; ... Warning: unchecked call to addas a member of the raw ... Warning: unchecked conversion ...
    (comp.lang.java.help)
  • warning: this used in base member initializer list
    ... I'm guessing the warning stems from the fact that I'm passing ... However, I'm not actually using 'this', just passing and storing ...
    (comp.lang.cpp)
  • Proxy/Stub Dll exported symbol Warnings
    ... I am receiving warnings during the dll proxy build step in a ATL COM server ... TESTAPPps.def: warning LNK4222: exported symbol 'DllGetClassObject' should ... DllGetClassObject @1 PRIVATE ...
    (microsoft.public.vc.atl)
  • Re: Proxy/Stub Dll exported symbol Warnings
    ... The make file output is as follows: ... TESTAPPps.def: warning LNK4222: exported symbol 'DllGetClassObject' ... DllGetClassObject @1 PRIVATE ...
    (microsoft.public.vc.atl)