OOP class question

  • Thread starter Thread starter mike
  • Start date Start date
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
 
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)?
 
Back
Top