G
Gaetan
hi
i have 2 classes A1 and A2 implementing a problem with 2 different
ways
i also have 2 other classes X1 and X2 implementing an other problem
i need classes that provide A1+X1 methods, A1+X2, A2+X1 and A2+X2:
interface A
class A1 implements A
class A2 implements A
interface X
class X1 implements X
class X2 implements X
(note: each class add custom public methods that cannot be in the
interface.
class A1X1 inherits A1, inherits X1
class A1X2 inherits A1, inherits X2
class A2X1 inherits A2, inherits X1
class A2X2 inherits A2, inherits X2
In pure C++ it was realy simple, but in C# (and VB) I cannot do that!
and i cannot use C++ in my project.
The only way to have multiple inheritance is to use interface... but
where is the interest to write 4 times the same code in
implementation!!!?
I like to use classes to store function to not write them sevral
times, so i don t think using inheritance with interfaces is a good
idea (because interface doesn t containt code).
I'm used to have interfaces in C++ on top of my hierarchy and have
multiple inheritance between lower classes and i cannot do this now !
I know it s the same problem in java so there should be a way (a
receipe?) to avoid multiple inheritance.
i have 2 classes A1 and A2 implementing a problem with 2 different
ways
i also have 2 other classes X1 and X2 implementing an other problem
i need classes that provide A1+X1 methods, A1+X2, A2+X1 and A2+X2:
interface A
class A1 implements A
class A2 implements A
interface X
class X1 implements X
class X2 implements X
(note: each class add custom public methods that cannot be in the
interface.
class A1X1 inherits A1, inherits X1
class A1X2 inherits A1, inherits X2
class A2X1 inherits A2, inherits X1
class A2X2 inherits A2, inherits X2
In pure C++ it was realy simple, but in C# (and VB) I cannot do that!
and i cannot use C++ in my project.
The only way to have multiple inheritance is to use interface... but
where is the interest to write 4 times the same code in
implementation!!!?
I like to use classes to store function to not write them sevral
times, so i don t think using inheritance with interfaces is a good
idea (because interface doesn t containt code).
I'm used to have interfaces in C++ on top of my hierarchy and have
multiple inheritance between lower classes and i cannot do this now !
I know it s the same problem in java so there should be a way (a
receipe?) to avoid multiple inheritance.