Click to See Complete Forum and Search --> : Design Question


asafaa
December 26th, 2006, 04:48 AM
I have two different abstract classes "Translate" and "PaintIt".

In these classes ,some functions are abstract and some aren't (they already defined and will function the same in every class that will inherit from this abstract class).

i have a third class "MyDiary" that have to inherit from these two classes.
as far as i know , multiple inheritance works only with interfaces which are full abstract classes without any defined classes in them.

so the problem is that i can't make the "MyDiary" inherit the two classes "Translate" and "PaintIt".

How do i solve this problem ?
How do i make the "MyDiary" class inherit two other classes that are not interfaces?

petes1234
December 26th, 2006, 09:03 AM
Could you give one of the base classes a parent class that is fully abstract and have your new class inherit that interface?

asafaa
December 26th, 2006, 10:44 AM
if i will make an interface which will be the parent of "Translation" and "PaintIt" and make "MyDiary" inherit from that interface , i wouldn't be able to use "PaintIt" and "translation" at all , i will only be able to use the new interface.

i want the "MyDiary" class to use the both "Translation" and "PaintIt" function. The abstract classes ,to implement and the non-abstract ,to use.

exterminator
December 26th, 2006, 10:54 AM
You cannot do that directly.

Have two interfaces ITranslatable and IPaintable that those abstract classes Translate and PaintIt partially implement (if needed). MyDiary implements the two interfaces completely. You can copy-paste those partial implementations into MyDiary from Translate/PaintIt, if they are same. Moreover, do your abstract classes serve any purpose? What purpose?