#include <iostream> // We can define an enum to represent bits. // We can use formulas and the previous values to assign new values. // Here, we use the bit shift to set keZero = 1, keOne = 2, keTwo = 4. enum EBit {keZero = 1, keOne = keZero << 1, keTwo = keOne << 1}; int main() { using namespace std; // Create an instance of the type and assign it the value keTwo. EBit eMyBit = keTwo; cout << "Bit enum value = " << eMyBit << endl; // Output the constant enum values. cout << "keZero = " << keZero << endl; cout << "keOne = " << keOne << endl; cout << "keTwo = " << keTwo << endl; // Keep the console window open. cin.get(); return 0; }
© 20072025 XoaX.net LLC. All rights reserved.