bitset - STL C++

bitset<N>:::operator!=()

Declaration

bool bitset<N>::operator!=(const bitset<N>& kqrRightSide) const;

Description

This is the member function operator!=() for the bitset class template. This function compares two bitsets and returns true if the two bitsets are not equal. Otherwise, it returns false.

Header Include

#include <bitset>

Example

#include <bitset>
#include <iostream>

int main()
{
	using namespace std;

	// Create a bitset
	bitset<4> qBits1(11);
	bitset<4> qBits2(3);
	cout << "bitset<4> #1: "<< qBits1 << endl;
	cout << "bitset<4> #2: "<< qBits2 << endl;

	// Shift the bits in the bitset
	cout << qBits1 << ((qBits1 != qBits2) ? " is not " : " is ")
		<< "equal to " << qBits2 << endl;
	cout << qBits1 << ((qBits1 != qBits1) ? " is not " : " is ")
		<< "equal to " << qBits1 << endl;

	// Keep the window open
	cin.get();
	return 0;
}

Output

bitset<N>::operator!=() Output
 

© 2007–2024 XoaX.net LLC. All rights reserved.