位标志只能在初始化时指定大小,后面不能再改
#include <iostream>
#include <bitset>
using namespace std;
int main(int argc, char const *argv[]) {
bitset<4> fourbit("1011");
cout << fourbit << endl;
cout << "Num of 1: " << fourbit.count() << endl;
bitset<4> fourbit2(~fourbit);
cout << fourbit2 << endl;
bitset<4> fourbit3 = fourbit.flip();
cout << fourbit3 << endl;
bitset<8> eightbit(255);
cout << eightbit << endl;
return 0;
}
1011
Num of 1: 3
0100
0100
11111111