C ++替代运算符表示
以下是各种运算符的替代关键字(如下),所有这些关键字的操作与其主要标记相似。例如:和的行为与&相同,而_eq的行为与&=相同,依此类推。
关键字是
替代运算符表示形式的C++示例
/*
C ++示例演示使用
替代运算符关键字
*/
#include <iostream>
#include <bitset>
using namespace std;
int main(){
int a = 10;
bitset<4> value("1111");
bitset<4> mask1("1010");
//和(或不是)not_eq关键字
cout << "a: " << a << endl;
cout << "(a>5 and a<20): " << (a > 5 and a < 20) << endl;
cout << "(a>5 or a<20): " << (a > 5 or a < 20) << endl;
cout << "not(a>5 and a<20): " << not(a > 5 and a < 20) << endl;
cout << "(a not_eq 5): " << (a not_eq 5) << endl;
//bitand,bitor,compl和and_eq,or_eq-
//xor,xor_eq关键字
cout << "value: " << value << endl;
cout << "mask1: " << mask1 << endl;
cout << "(value bitand mask1): " << (value bitand mask1) << endl;
cout << "(value bitor mask1): " << (value bitor mask1) << endl;
cout << "(value xor mask1): " << (value xor mask1) << endl;
cout << "compl value: " << compl value << endl;
value and_eq mask1;
cout << "value and_eq mask1: " << value << endl;
value or_eq mask1;
cout << "value or_eq mask1: " << value << endl;
value xor_eq mask1;
cout << "value xor_eq mask1: " << value << endl;
return 0;
}输出结果
a: 10 (a>5 and a<20): 1 (a>5 or a<20): 1 not(a>5 and a<20): 0 (a not_eq 5): 1 value: 1111 mask1: 1010 (value bitand mask1): 1010 (value bitor mask1): 1111 (value xor mask1): 0101 compl value: 0000 value and_eq mask1: 1010 value or_eq mask1: 1010 value xor_eq mask1: 0000
热门推荐
1 带狗狗训练
4 听力训练狗狗
6 怎训练狗狗
7 腹肌训练狗狗
8 网球训练狗狗
9 记叙文训练狗狗
10 狗狗太凶怎么训练
11 核心力量训练狗狗
12 狗狗乱叫怎么训练
13 发音训练狗狗
14 怎么训练狗狗叼东西给主人
15 荆州训练狗狗
16 篮球训练狗狗
17 做训练狗狗
18 训练狗狗坐姿