// std_string.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <string>
#include <iostream>
#include <fstream>
#include <bitset>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
bitset<16> bitvec1(0xffff); //0-15为1
bitset<32> bitvec2(0xffff); //0-15为1,16—31为0
bitset<128> bitvec3(0xffff); //0-31为1,32-127为0
string str("1100");
bitset<32> bitvec4(str); //反向转换:bitec4:0011
string str1("1111111000000011001101");
bitset<32> bitevec5(str1,5,4); //4 bit starting at str1[5],1100
bitset<32> bitvec6(str1,str1.size()-4) //using last 4 bits
cout<<bitvec2[16];
return 0;
}
//
#include "stdafx.h"
#include <string>
#include <iostream>
#include <fstream>
#include <bitset>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
bitset<16> bitvec1(0xffff); //0-15为1
bitset<32> bitvec2(0xffff); //0-15为1,16—31为0
bitset<128> bitvec3(0xffff); //0-31为1,32-127为0
string str("1100");
bitset<32> bitvec4(str); //反向转换:bitec4:0011
string str1("1111111000000011001101");
bitset<32> bitevec5(str1,5,4); //4 bit starting at str1[5],1100
bitset<32> bitvec6(str1,str1.size()-4) //using last 4 bits
cout<<bitvec2[16];
return 0;
}