If I remember this correctly, there are at least two ways to create mixins in C ++. This comes from some very old (1995) textbook that I saw (but it almost completely disappeared from the Internet).
Firstly,
class MixinBase { public : void f() {}; }; template<class T> class Mixin : public T { public: void f() { T::f(); T::f(); } }; template<class T> class Mixin2 : public T { public : void g() { T::f(); T::f(); } }; int main() { Mixin2<Mixin<MixinBase>> mix; mix.g(); }
Or another way uses virtual inheritance and sibling calls:
class Base { public : virtual void f() = 0; }; class D1 : public virtual Base { public : void g() { f(); } }; class D2 : public virtual Base { public : void f() { } }; class D : public D1, public D2 { }; int main() { D d; dg(); }
Now both versions implement mixins because Mixin and Mixin2 are independent classes, but they can still communicate. And you can create software from such modules, and then just bind these modules to one large software. The same thing happens between D1 and D2 in virtual inheritance. It is important to note that in the mixin project, different modules live inside the same C ++ object. (oh and CRTP is a different method)
tp1 Aug 17 2018-11-11T00: 00Z
source share