I've stumbled upon a diamond inheritance problem, and I am not sure of the best solution. The following code works and has no diamond problem:
class Element { /* pure virtual functions */ };
class Diode : public Element {};
class Thyristor : public Diode {};
I don't like the public inheritance though, because a Thyristor is not a Diode, it just acts like a Diode often enough that I want to use a lot of the Diode code. I can make it work by using composition rather than inheritance, but that results in duplication of internal data structures between Diode and Thyristor which I don't like. What I would like to do is use private inheritance. If I do that, then Thyristor would also need to inherit publicly from Element:
class Thyristor : public Element, private Diode {};
The potential problem is that I have now created a diamond, as Element is inherited directly and through Diode. Is this a problem if Element is a pure virtual function? If it is, what is the proper way to solve this problem, making changes only to the Thyristor class?