== Quote from Stanislav Blinov (bli...@loniir.ru)'s article > In C++ I sometimes have similar problems, especially with multiple > inheritance. Though, as Jonathan mentioned, those problems are even more > annoying because of hijacking: you don't always immediately notice them. > Long ago I've decided to always employ conversion methods for such > cases, which in D might look like this: > class C : I2{ > I1 toI1() { return this; } > I2 toI2() { return this; } > } > This unclutters the code a bit, i think: > void main(){ > func((new C).toI2()); // compare with func(cast(I2)(new C)); > C c = new C; > func(c.toI1()); // compare with(cast(I1)c); > } > The calls to conversion methods could be even shorter if they were > properties, because of omitted parens. Anyway, once I stuck to this > strategy, it never failed me.
I employ this strategy as well but I thought I would like to try the overload method, just to experiment :)