MainClass.h:
namespace Alpha{ enum class Parameters; }
namespace Beta { enum class Parameters; }
MainClass{
public:
enum class Type{ Type_A, Type_B };
MainClass(const Type t);
void DoStuff(const Parameters p);
private:
void doesStuff(const int p_val);
};
MainClass.cpp:
/* define values for Alpha::Parameters, Beta::Parameters here or elsewhere, and included */
MainClass::MainClass(const Type t){
/* not sure how to do this. But essentially by switching based on 't' use either Alpha::Parameters or Beta::Parameters */
}
MainClass::DoStuff(const Parameters p){
int p_value = static_cast<int>(p);
doesStuff(p_value);
}
That's what I'd like to be able to do. Is this possible? Realistically it'd be nice if enum class just behaved like a class with inheritance, but I know I can't do that. The more I try to rewrite this, it just keeps spiraling out until I'd practically be left writing specific classes for each case (I have more than just the two in the example). But the code is all so similar, really.
I also know the alternative would just be to allow DoStuff(const Parameters p) to be just a DoStuff(const int p_val) and do the static cast externally... but then I have to do all the static casting elsewhere, and I don't get the nice typechecking of enum class.
If it's not possible, that's fine... but too bad if so.