+ 4
Why vectors?
What are they used for?
3 Réponses
+ 2
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<int> a;
a.push_back(5);
a.push_back(3);
a.push_back(7);
for(int i=0; i<a.size();i++){
cout<<a[i]<<endl;
}
return 0;
}
+ 1
arrays is a type of static data structure and vector is a dynamic data structure.
0
vectors are like arrays, but vectors can grow dinamically to allocate new elements, when needed to.