Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Base class calling method in derived class?

Status
Not open for further replies.

dragonwell

Programmer
Oct 21, 2002
863
US
I have run into something that confuses me. Maybe it is just a bad overall design, maybe not. Anyway, I have a class (my "base" class) that uses an internal "helper method" in one of it's public methods. I need for a derived class to call this inherited method as well, but when it does I want to be able to override the helper method in the derived class. So, in my derived class I want to be able to tell it "base.ExecuteMethod()" but have base uses the overridden version in the derived class instead of it's own helper method.

Does that make sense????

Should I try to post an example?

Thanks.

David [pipe]


 
>> Does that make sense????

Sure... maybe... if i follow it correctly. It may in fact be a bad design, or could be improved, but there is not enough in your post to tell.

>> Should I try to post an example?

That could help.

-pete
 
What language are you programming with?

If you're doing .NET, then its very easy to do as long as you have different signatures (i.e. both have the same name, but take different parameters or have different outputs).

Question though: if your derived class isn't going to use its version of the function, why not just get rid of it or, if it is needed, rename it something else?

D'Arcy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top