#include#include using namespace std; int main() { bitset<8> myFlags(0x03); if (myFlags.test(1)) { cout << "Second flag is set" << endl; } return 0; }
#includeThis example is similar to Example 1, but the bitset has more bits, which allows us to check for a flag at a higher index. The `Item HasFlag` function is typically found in the C++ Standard Library, although it may also be included in external libraries.#include using namespace std; int main() { bitset<16> myFlags(0x0a01); if (myFlags.test(4)) { cout << "Fifth flag is set" << endl; } return 0; }