| (Bitwise Or) Operator - C++ Operator

C++ examples for Operator:Bit Operator

Introduction

The bitwise or operator returns a value that contains all of the set bits from the left and right side of the operator.

Demo Code

#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    int leftBits{ 0x00011000 };
    int rightBits{ 0x00010100 };
    cout << showbase << hex;
    cout << "Result of 0x00011000 | 0x00010100: " << (leftBits | rightBits) << endl;
    cout << "Result of 0x00011000 & 0x11100111: " << (leftBits | ~leftBits) << endl;

    return 0;//from  w ww  . jav  a2s .c  o  m
}

Result


Related Tutorials