命名空间
变体
操作

C++ 关键字: bitand

来自 cppreference.cn
< cpp‎ | 关键字
 
 
C++ 语言
表达式
替代表示
字面量
布尔字面量 - 整数字面量 - 浮点字面量
字符字面量 - 字符串字面量 - nullptr (C++11)
用户定义 (C++11)
工具
属性 (C++11)
类型
typedef 声明
类型别名声明 (C++11)
类型转换
内存分配
类特有的函数属性
explicit (C++11)
static

特殊成员函数
模板
杂项
 
 

[编辑] 用法

[编辑] 示例

#include <bitset>
#include <iostream>
 
using bin = std::bitset<8>;
 
void show(bin z, const char* s, int n)
{
    if (n == 0) std::cout << "┌────────────┬──────────┐\n";
    if (n <= 2) std::cout << "│ " <<s<<  " │ " <<z<<" │\n";
    if (n == 2) std::cout << "└────────────┴──────────┘\n";
}
 
int main()
{
    bin x{"01011010"};  show(x, "x         ", 0);
    bin y{"00111100"};  show(y, "y         ", 1);
    bin z = x bitand y; show(z, "x bitand y", 2);
}

输出

┌────────────┬──────────┐
│ x          │ 01011010 │
│ y          │ 00111100 │
│ x bitand y │ 00011000 │
└────────────┴──────────┘

[编辑] 参阅