vc++中画线时xor_C ++'xor_eq'关键字和示例

vc++中画线时xor

"xor_eq" is an inbuilt keyword that has been around since at least C++98. It is an alternative to ^= (EXCLUSIVE-OR Assignment) operator and it mostly uses for bit manipulations.

“ xor_eq”是一个内置关键字,至少从C ++ 98起就存在。 它是^ = ( EXCLUSIVE-OR Assignment )运算符的替代方法,它主要用于位操作。

The xor_eq keyword performs EXCLUSIVE-OR operation and assigns the result to the left/first operand.

xor_eq关键字执行EXCLUSIVE-OR运算,并将结果分配给左/第一个操作数。

Syntax:

句法:

    operand_1 xor_eq operand_2;

Here, operand_1 and operand_2 are the operands.

在这里,操作数_1和操作数_2是操作数。

Example:

例:

    Input:
    bitset<4> value("1100");
    bitset<4> mask ("1010");
        
    value xor_eq mask;

    Output:
    value = 0110

演示使用“ xor_eq”关键字的C ++示例 (C++ example to demonstrate the use of "xor_eq" keyword)

// C++ example to demonstrate the use of
//'xor_eq' keyword

#include <iostream>
#include <bitset>
using namespace std;

int main()
{
    //bitsets
    bitset<4> value("1011");
    bitset<4> mask1("1100");
    bitset<4> mask2("0100");

    // before operation
    cout << "value: " << value << endl;
    cout << "mask1: " << mask1 << endl;
    cout << "mask2: " << mask2 << endl;

    value xor_eq mask1;

    cout << "After operation (1)...\n";
    cout << "value: " << value << endl;

    value xor_eq mask2;

    cout << "After operation (2)...\n";
    cout << "value: " << value << endl;

    return 0;
}

Output:

输出:

value: 1011
mask1: 1100
mask2: 0100
After operation (1)...
value: 0111
After operation (2)...
value: 001


翻译自: https://www.includehelp.com/cpp-tutorial/xor_eq-keyword-with-example.aspx

vc++中画线时xor

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值