The wiki says:
The elements of a vector are stored contiguously. AND
Vectors allow random access; that is, an element of a vector may be referenced in the same manner as elements of arrays (by array indices).
So why can't we input the elements of a vector as:
vector<int> v;
for(int i=0;i<3;i++)
{
cin>>v[i];
}
vectora size, yes. Otherwise it starts with 0 elements. If you have a fixed size, you can usestd::arrayinstead. But what is wrong withpush_back?std::arrayinstead.