1
#include <iostream>
#include<vector>
using namespace std;
bool a;
char c;
int main() {
vector<bool> bVec = { true,false,true,false,true};
vector<char> cVec = { 'a', 'b', 'c', 'd', 'e' };
cout<<sizeof(bVec);cout<<endl;
cout<<sizeof(cVec);
cout<<endl;
cout<<sizeof(a);
cout<<endl;
cout<<sizeof(c);
return 0;
}
이 코드를 컴파일 할 때 cVec의 크기는 20이고 bvec의 크기는 12입니다. 왜 크기가 다른가요?두 벡터의 크기가 왜 <bool> bVec = {true, false, true, false, true}; 벡터 <char> cVec = { 'a', 'b', 'c', 'd', 'e'}; 다르다?
'std :: vector < bool > '은 동물의 특별한 종류입니다. http://stackoverflow.com/questions/17794569/why-is-vectorbool-not-a-stl-container를 참조하십시오. –