I am really strugling with an inheritance issue when using what should be strongly typed enums - however the enums seems to be ambigious when used through inheritance.
Im using g++ (GCC) 4.7.2
enum class AE { V1 };
enum class BE { V2 };
enum class CE { V3 };
struct A { void set(AE enumval) { } };
struct B { void set(BE enumval) { } };
struct C { void set(CE enumval) { } };
struct combined : A, B, C { };
struct all_in_one {
void set(AE enumval) { }
void set(BE enumval) { }
void set(CE enumval) { }
};
void function()
{
combined inherited_obj;
// compile errors - ambigious funtion call
inherited_obj.set(AE::V1);
inherited_obj.set(BE::V2);
inherited_obj.set(CE::V3);
all_in_one simple_obj;
// works like a charm...
simple_obj.set(AE::V1);
simple_obj.set(BE::V2);
simple_obj.set(CE::V3);
}
I cant find any information why it shouldn't work this way. Am I missing something obvious.
Aucun commentaire:
Enregistrer un commentaire