+ 8

Any one tell please about...... vector......in c++;

31st Aug 2017, 11:32 AM
Nishant Shekhar Soni
Nishant Shekhar Soni - avatar
5 Answers
+ 14
Vector is a template class which can be used as a replacement for plain arrays. E.g. #include <vector> #include <iostream> int main() { std::vector<int> obj = {1, 2, 3, 4}; // and ofc, there are benefits to use vectors over arrays, for instance, built-in class methods. std::cout << obj.size() << std::endl; std::cout << obj.push_back(5); // and more. Try em out for yourself. }
31st Aug 2017, 11:52 AM
Hatsy Rei
Hatsy Rei - avatar
+ 5
thanks...friends
31st Aug 2017, 2:39 PM
Nishant Shekhar Soni
Nishant Shekhar Soni - avatar
+ 4
One advantage of vector that was not given is the fact that it resizes itself when needed, you do not have to care about overflowing the array. At least less than for a normal array because it will allocate another contiguous space if needed.
31st Aug 2017, 2:34 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 3
31st Aug 2017, 2:09 PM
Manual
Manual - avatar
+ 1
a vector is like an array, but u can change the size and add and remove numbers/characters. Here's a code all about vectors https://code.sololearn.com/caYxU5xC3V22/?ref=app
1st Sep 2017, 7:53 PM
HJ🐓TDM