I'm trying to make a couple of enums work, however mingW isn't
compiling it because it says the previous declaration of none
conflicts. is there a way to solve this?
namespace Namespace
{
enum Gender // m or f
{
none = 0,
male = 1 << 0,
female = 1 << 1
};
enum LookingFor
{
none = 0,
friendship = 1 << 0,
dating = 1 << 1,
relationship = 1 << 2,
randomPlay = 1 << 3,
whateverICanGet = 1 << 4
};
}
> I'm trying to make a couple of enums work, however mingW isn't
> compiling it because it says the previous declaration of none
> conflicts. is there a way to solve this?
There is a plethora of ways dealing with enums, and unfortunately no
standard way everyone agrees upon.
Two popular ways are wrapping each enum in a class or namespace of
it's own:
namespace Gender
{
enum enum_t { ... };
}
or
class Gender
{
enum enum_t { ... };
};
With both approaches, you can have functions like toString that are
found by ADL.
I'd suggest you do something based on one of these approaches.
Regards,
Jens
> Would you be kind to show how the boolean operators work on these?
> Would it be like Gender::male?
I'm not sure what you mean by boolean operators.
Gender::male would be a way to refer to an enumerator, eg.
std::string toString(Gender::enum_t e)
{
switch(e)
{
case Gender::male: return "male";
case Gender::female: return "male";
}
throw std::runtime_error("invalid enum");
}
Regards,
Jens
> std::string toString(Gender::enum_t e)
> {
> switch(e)
> {
> case Gender::male: return "male";
> case Gender::female: return "male";
> }
>
> throw std::runtime_error("invalid enum");
> }
Bisexuality error.
--
Salu2
facebook::Gender::Gender name;
name = facebook::Gender::male;