compl c++_C ++’compl’关键字和示例

compl c++_C ++’compl’关键字和示例complc compl isaninbuiltk 98 Itisanaltern Compliment operator

大家好,欢迎来到IT知识分享网。

compl c++

“compl” is an inbuilt keyword that has been around since at least C++98. It is an alternative to ~ (Compliment) operator and it mostly uses for bit manipulations.

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

The compl keyword inverts all of the bits of the operand.

compl关键字将操作数的所有位取反。

Syntax:

句法:

 compl operand  

Here, operand is the operand.

在此, 操作数是操作数。

Example:

例:

 Input: bitset<4> value("1100"); value = compl value; Output: value = 0011  

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

// C++ example to demonstrate the use of // 'compl' keyword #include <iostream> #include <bitset> using namespace std; int main() { 
    //bitsets bitset<4> value("1011"); // before operation cout << "value: " << value << endl; value = compl value; cout << "After operation (1)...\n"; cout << "value: " << value << endl; value = compl value; cout << "After operation (2)...\n"; cout << "value: " << value << endl; return 0; }  

Output:

输出:

value: 1011 After operation (1)... value: 0100 After operation (2)... value: 1011  

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

compl c++

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://haidsoft.com/141284.html

(0)
上一篇 2025-05-18 15:20
下一篇 2025-05-18 15:26

相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注微信