superboy_lin 发表于 2017-3-21 13:47:54

新人求助C++

小程序中与 或 非操作练习,代码如下
      cout << "Logical AND ,& with 00001111" << endl;
        bitset<8>BitwiseAND = (0X0F & InputBits);
        cout << "00001111 & " << InputBits << "=" << BitwiseAND << endl;
编译出现以下错误:
Error        4        error C2677: binary '|' : no global operator found which takes type 'std::bitset<8>' (or there is no acceptable conversion)        d:\cplus\cplus03082\cplus03082\myfirst.cpp        849        1        CPlus03082
请问该怎么修改?

lumber2388779 发表于 2017-3-22 10:52:00

你的报错跟你贴的代码不一样啊,报错指的是|符号,你贴的是&符号
你是不是用bitset<8>类型去使用|了,这个类型不支持| & 操作的
你参考下http://blog.sina.com.cn/s/blog_62fc96e601018qd4.html怎么使用

superboy_lin 发表于 2017-3-28 22:40:37

貌似顿开 谢谢那么详细的讲解
页: [1]
查看完整版本: 新人求助C++