C++ bitset test() 函数

2024 年 8 月 30 日 | 阅读 2 分钟

C++ bitset 的 test() 函数用于测试位置 p 上的位是否被设置。如果位置 p 上的位被设置,则返回 true,否则返回 false。

语法

参数

p:它接受一个参数,用于指定要测试的位的索引。

返回值

如果位置 p 上的位被设置,则返回 true;如果未被设置,则返回 false。

示例 1

输出

bitset b is set at position 3 : 0
 bitset b is set at position 2 : 1

示例 2

输出

bitset b is set at position 3 : 0
bitset b1 is set at position 2 : 1

示例 3

输出

bitset is set at postion 1
下一主题C++ bitset