lundi 23 janvier 2017

why the size of two vector

#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;
}

When i compile this code i get size of cVec as 20 and size of bvec as 12 . but why the sizes are different?

Aucun commentaire:

Enregistrer un commentaire