我写了以下几行:
std::bitset<4> bitvec; //bitset 0000
std::bitset<4> addition; //bitset 0000
addition.set(0); //setting the least significant bit
std::cout << addition << std::endl; //output 0001
std::cout << std::endl;
for(int x = 0; x != 16; ++x) { //addition loop
std::cout << bitvec << std::endl; //output
bitvec &= addition; //binary AND
}
std::cout << std::endl;
我预计输出是:
0000
0001
0010
0011
0100
0101
....
但循环只输出'0000'。我缺少什么基本概念?