OOP class question

M

mike

I have a function in one class that I have discovered I need in
another class also. What is the best way to do this? Create a 3rd
class and inherit it in the 1st two?

Thanks
Mike
 
C

cody

I have a function in one class that I have discovered I need in
another class also. What is the best way to do this? Create a 3rd
class and inherit it in the 1st two?

Either that or you make it static so you have access to it everwhere.
The question here really is: does this method belong to these two classes
(in which cas you use inheritance) or is it of a generic kind that could
theoretically be useful for other classes too (in which case you use a
static method)?
 

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

Top