Unscoped enumeration WORKS with the OR operator where the scoped one does not... WHY and how to work with it?
The enum type type-name is unscoped. Prefer 'enum class' over 'enum' (Enum.3)
#include <iostream>
enum eDogType
{
eHusk = 0,
eGold,
eAus,
eGerm,
ePud
};
int main()
{
eDogType eDog1 = eDogType::eAus;
eDogType eDog2 = eDogType::eGerm;
eDogType eDog = static_cast<eDogType>(eDog1 | eDog2); // WORKS
std::cout << "Hello World: " << eDog << "\n";
return(0);
}
Scoped enumeration fails in the OR operator
#include <iostream>
enum class eDogType
{
eHusk = 0,
eGold,
eAus,
eGerm,
ePud
};
int main()
{
eDogType eDog1 = eDogType::eAus;
eDogType eDog2 = eDogType::eGerm;
eDogType eDog = static_cast<eDogType>(eDog1 | eDog2); // FAILS: C++ no operator matches these operands
std::cout << "Hello World: " << eDog << "\n";
return(0);
}