I was not understanding vector::operator[] functionality. I was assuming I can do an assignment as shown in code below. But the size of array was not updated after adding elements to it. Changing it to push_back works, any hint on what I could be doing wrong?
1 2 3 4 5 6 7 8 9 10
cin>>count1>>count2; //Get the count of 2 lines
a.reserve(count1);
b.reserve(count2);
for(int i=0;i<count1;i++){
cin>>temp;
cout<<"Temp is"<<temp<<endl;
a[i]=temp;
cout<<"a[i] is"<<a[i]<<endl;
}
cout<<"a size is "<<a.size()<<endl;