Cpp-standard-library-cpp-bitset-operator-not-equal-to

提供:Dev Guides
移動先:案内検索

C ++ビットセットライブラリ-operator!=関数

説明

C ++関数* *std
bitset :: operator!=* *は、2つのビットセットが等しいかどうかをテストします。

宣言

次に、std
bitset :: operator!=関数形式std :: bitsetヘッダーの宣言を示します。

C 98

bool operator!= (const bitset& other) const;

C 11

bool operator!= (const bitset& other) const noexcept;

パラメーター

*other* -別のビットセットオブジェクト。

戻り値

両方のビットセットが等しくない場合はtrue、そうでない場合はfalseを返します。

例外

このメンバー関数は例外をスローしません。

次の例は、std
bitset :: operator!=関数の使用法を示しています。
#include <iostream>
#include <bitset>

using namespace std;

int main(void) {
   bitset<4> b1("1010");
   bitset<4> b2("1110");

   if (b1 != b2)
      cout << "Both bitsets are not equal." << endl;

   b1 = b2;

   if (!(b1 != b2))
      cout << "Both bitsets are equal." << endl;

   return 0;
}

上記のプログラムをコンパイルして実行すると、次の結果が生成されます-

Both bitsets are not equal.
Both bitsets are equal.