C++位集reset()函数用于重置位集的所有位。如果将索引作为参数,它将重置该索引的位。
reset(); reset(int index);
index - 它使用一个参数作为索引,但这不是强制性的。
此函数不返回任何值。
#include <iostream> #include <bitset> using namespace std; int main() { bitset<4> b(string("1001")); cout<< "before applying reset method : " << b <<'\n'; cout<< "after applying reset method : " <<b.reset(); return 0; }
输出:
before applying reset method : 1001 after applying reset method : 0000
#include <iostream> #include <bitset> using namespace std; int main() { bitset<4> b(string("1001")); cout<< "before apllying reset method : " << b <<'\n'; cout<< "after apllying reset method : " <<b.reset(3) <<'\n'; cout<< "after apllying reset method : " <<b.reset(0); return 0; }
输出:
before applying reset method : 1001 after applying reset method : 0001 after applying reset method : 0000
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)