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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top