I want to prefer variables from one class in diamond inheritance.
This is the code:
class DiamondBase { protected: int x; };
class DiamondSonA: public DiamondBase {};
class DiamondSonB: public DiamondBase {};
class DiamondGS: public DiamondSonA, public DiamondSonB {
void func() { x = x; }
};
I get an error
error: reference to ‘x’ is ambiguous
I can write address x
in func()
like this B::x
/ C::x
.
But I want somehow to prefer x
from class B
, and call it by x
.
Is it possible?
My main purpose it to tag classes using variables, and the diamond inheritance doesn't let me do it...
Thanks