// tbits.cpp: Set some bits and display the result
#include <iostream.h>
#include <stddef.h)
#include <limits.h>
#include <bits.h>
main()
{
const size_t SIZE = CHAR_BIT * sizeof(int);
bits<SIZE> flags;
enum open_mode {in, out, ate, app, trunc, binary};
flags.set(in);
flags.set(binary);
cout << "flags: "<< flags <<" (0x" << hex
<< flags.to_ushort() << ")" << endl;
cout << "binary?"
<< (flags.test(binary) ? "yes" : "no")
<< endl;
return 0;
}
Output
flags: 0000000000100001 (0x21)
binary? yes
// End of File