I'm trying to overload the & operator of an enum class, but I'm getting this compiler error: error: no match for 'operator&=' (operand types are 'int' and 'Numbers'). Any ideas about this?
#include <iostream>
using namespace std;
enum class Numbers : int
{
zero = 0,
one = 0x01,
two = 0x02
};
inline int operator &(int a, Numbers b)
{
return ((a) & static_cast<int>(b));
}
int main() {
int a=1;
a&=Numbers::one;
cout << a ;
return 0;
}