+ 8
Any one tell please about...... vector......in c++;
5 Réponses
+ 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.
}
+ 5
thanks...friends
+ 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.
+ 3
Here is a code using vectors
https://code.sololearn.com/cMMcFCTL93kQ/?ref=app
+ 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