+ 4

Why vectors?

What are they used for?

11th Mar 2017, 1:58 PM
Someone
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; }
11th Mar 2017, 2:10 PM
Владимир Говоровский
Владимир Говоровский - avatar
+ 1
arrays is a type of static data structure and vector is a dynamic data structure.
11th Mar 2017, 6:36 PM
mangesh singh
mangesh singh - avatar
0
vectors are like arrays, but vectors can grow dinamically to allocate new elements, when needed to.
11th Mar 2017, 2:15 PM
Welliton Malta
Welliton Malta - avatar