61STL_vector
基本概念示例代码
基本概念
bitset中容量大小是固定的,而vector< bool >的大小是可以动态调整的
实例化vector< bool >
示例代码
#include <iostream>
#include <vector>
#include <bitset>
using namespace std
;
int main()
{
bitset
<4> a
;
cout
<< a
<< endl
;
bitset
<5> b(string("10101"));
cout
<< b
<< endl
;
vector
<bool
> x(3);
x
[0] = true
;
x
[1] = true
;
x
[2] = false
;
x
.push_back(true
);
for(size_t nIndex
=0; nIndex
< x
.size(); ++nIndex
)
cout
<< x
[nIndex
];
cout
<< endl
;
x
.flip();
for(size_t nIndex
=0; nIndex
< x
.size(); ++nIndex
)
cout
<< x
[nIndex
];
cout
<< endl
;
return 0;
}
转载请注明原文地址: https://win8.8miu.com/read-1549020.html