Inheritance C++ (Diamond dread) -
i have following problem inheritance (i love google it, don't know correct keywords seems).
i have module class implements imodule interface function a(). have clientmodule class inherits module class , implements iclientmodule interface function b() inherits imodule interface. starting ambiguity , double inheritance problems.
here class diagram should tell bit more problem:

i need have separated access module class imodule interface , clientmodule iclientmodule interface offers access imodule interface well.
make iclientmodule not inherit imodule (and rename iclient). in clientmodule, inherit module , implement iclient.
or, alternative solution written after reading comments:
make clientmodule class inherit iclientmodule in example. however, instead of inheriting module, give clientmodule member variable module, , forward calls member needed. this:
class imodule { virtual void a() {} }; class module : public imodule { ... }; class iclientmodule : public imodule { virtual void b() {} }; class clientmodule : public iclientmodule { // ... virtual void a() { _module.a(); } private: module _module; }; however, still better avoid mashing these , use original solution.
Comments
Post a Comment