If create an enum inside a struct for readability, mentioned here How to avoid name conflicts for two enum values with the same name in C++?
I am planning to add more enums, here and in other situations, I just wanted to know why the struct wasn't compiling. Coming from C# and Java I was hoping for a simpler syntax –
And have the struct as the parameter to a constructor in a class, I cannot call it from the main.cpp of a console application. It gives me the error **no matching function for call toBarEnc::BarEnc(BarEnc::Scheme::eScheme)’ ** main.cpp
Here is the Class
class BarEnc {
public:
struct Scheme
{
enum eScheme
{ ADJ1M2, ADJ3M6
};
};
BarEnc();
BarEnc(BarEnc::Scheme scheme);
}
in main.cpp I call it
BarEnc barEnc = BarEnc(BarEnc::Scheme::ADJ3M6);
But if I change the parameter to an int in the constructor the code compiles
BarEnc(int scheme);
If I change it to the enum the code compiles
BarEnc(BarEnc::Scheme::eScheme scheme);
But when it is a struct, it does not compile. I am relative new to C++, using GCC 4.6 to compile on Linux, using 99 standard.
Is there a reason why I can't use a struct as a parameter?