#include <iostream>
using namespace std;
enum N {
A = 0x00000001,
B = 0x00000010,
C = 0x00000100,
};
void check(int a)
{
if (a & A) {
cout << "A" << endl;
}
if (a & B) {
cout << "B" << endl;
}
if (a & C) {
cout << "C" << endl;
}
}
int main()
{
printf("传入一个枚举: \n");
N a = A;
check(a);
printf("\n===============\n");
printf("位操作后传入一个int值:\n");
int b = A | B | C;
check(b);
}
运行结果:
传入一个枚举:
A
===============
位操作后传入一个int值:
A
B
C