读书人

bitset变量不能用于位运算吗?该怎么解

发布时间: 2012-03-30 17:32:09 作者: rapoo

bitset变量不能用于位运算吗?
如题~~
bitset变量是不是只能和同样位数的bitset变量进行位运算~
不能与其他字面常量或者int,double之类的进行位运算吗?
为什么?有没有详细点的解释下?我百度不到这方面的问题~~

[解决办法]
基本上,你可以把字面常量放入bitset中,然后跟另一个bitset运算即可。
[解决办法]
bitset很简单的。最权威的参考资料在这里(还有很多例子):
http://www.cplusplus.com/reference/stl/bitset/

看看就明白了。
[解决办法]
楼主 表示本来也打算给你那网址的~~


http://www.cplusplus.com/reference/stl/bitset/operators/

不懂用的话可以看下examples


lhs
Left-hand side bitset object (global functions). It must be of the same amount of bits as the right-hand side bitset object (i.e. with the same N template parameter).
rhs
Right-hand side bitset object.
For member functions, rhs must have the same amount of bits as the bitset object.
pos
Amount of bit locations to be shifted.
is,os
istream or ostream object from which a bitset object is respectively extracted or inserted. The format in which bitsets are inserted/extracted is binary (successions of 0's and 1's).

看一下粗体字
[解决办法]
没用过 猜测可以(:-D) 楼主写个用例试试!

读书人网 >C++

热点推荐