0

Are there any problems with the c++ code

vector<int> vec1 = {5, 2, 5, 2, 0}; vector<int> vec2; for(int i = 0; i < vec1.size(); ++i) vec2[i] = vec1[i];

5th Jan 2019, 7:09 AM
林克翰
2 Respuestas
+ 3
Moreover, I saw the second vector's size isn't defined. So, in your loop, write : vec2.push_back(vec1[i])
5th Jan 2019, 8:23 AM
Théophile
Théophile - avatar
+ 1
you need to include vector library first to work with vectors: #include <vector> Then everything will be fine!☺
5th Jan 2019, 7:46 AM
Botol
Botol - avatar