Am am currently working on a Phd project where I use C++ and a Finite Elemenet open source project called oofem to conduct my research. I have a problem concerning multpile inheritance. I have, to begin with three classes:
1 2 3
class Material {....}
class FluidDynamicMaterial : public Material {....}
class RVEMaterial : public Material {....}
Now, I want to create a fourth class that inherits both from FluidDynamicMaterial and RVEMaterial classes. Like:
class RVEStokesFlow : public RVEMaterial, public FluidDynamicMaterial {....}
When compiling I get the following error:
error: ‘oofem::Material’ is an ambiguous base of ‘oofem::rvestokesflow’
I cannot make changes in the classes Material and FluidDynamicMaterial since they come with the package and are used on numerous other places. RVEMaterial and RVEStokesFlow can be changed though. Why does it not work? And how can I solve this problem?
Can you inherit FluidDynamicMaterial in RVEMaterial instead of the base Material, then only inherit RVEMaterial in RVEStokesFlow. Perhaps call it RVEFluidMaterial if you have other types of RVE Materials as well.
So...
1 2 3 4
class Material {....}
class FluidDynamicMaterial : public Material {....}
class RVEFluidMaterial : public FluidDynamicMaterial {....}
class RVEStokesFlow : public RVEFluidMaterial {....}