Output is:Code:#include <iostream> #include <vector> using namespace std; typedef vector<int> intVector; int main() { intVector vInt1(5); vInt1[0]=1; cout<<vInt1.size()<<endl; cout<<vInt1.capacity(); return 0; }
5
5
which is supprising (at least for me)
I was expecting 1 5
Druring compiling I get two following warnings:
conversion from 'size_t' to 'unsigned int', possible loss of data
both for cout
I can get rid of them by casting to unsigned int
If someone can explain output.
whati is the difference between size() and capacity()