这个程序是有关std::bitset的简单实例。
#include程序运行结果如下:#include using namespace std;int main(){ bitset<32> bitv(0xffff); // bits 0 ... 15 are set to 1; 16 ... 31 are 0 bitv.set(30); bitv.reset(1); if(bitv.test(30)) cout << "bitv 30:" << "1" << endl; else cout << "bitv 30:" << "0" << endl; cout << "bitv: " << bitv << endl; return 0;}
bitv 30:1 bitv: 01000000000000001111111111111101