override verses hide

  • Thread starter Thread starter Tom Jones
  • Start date Start date
T

Tom Jones

I do not understand what is meant when someone states that a given method is
"hidden" verses overriden.

Would someone please provide a short example of both cases and why you might
want to "hide" a parent method's implementation verses simply overriding it
(ie take advantage of polymorphism)?

Thanks,
TJ
 
Hi Tom,

Suppose you have a method in a component which doensn't use "virtual" or
overridable keywords. It's not possible for you to override the method in
this case, you could only hide it.

Also, suppose you want to have a method in your derived class, which should
have the same name as the base class, but with different access specifiers,
the only possible way is to hide.

Using "new" keyword in method definitions helps you in these situations.

HTH,
- Rakesh Rajan
 
Back
Top