+ 3
What are vectors in c++?
are they really necessary to learn. if yes then can anybody explain me little bit of vector and you can also share some link for explaination.
4 Réponses
+ 12
Sure! i say you must!
Vectors is a container, just one of the features of the STL (Standard Template Library)
You'll find there also List, Array and many others containers.
STL has also algorithms, function and iterators.
They all comes really handy and a c++ programmer must know them.
In general they are real c++ style.. whit parameterized data, encapsulation.. they are OOP!
For example <vector> , which is a container, imagine you have some data to manage of undefined amount, if you plan to use array and dynamic memory the best approach would be to create a class whit specific methods for access data, add/delete elements..
Then.. you don't have to..
use a container instead :)
Now it's important you know what container to choose!
I recommend you to learn all the STL , you can use books, cppreference, stack overflow, google..
Vector and containers should be the best point to start!
enjoy!
[EDIT] And also Hatsy course! of course!
+ 5
C++ has a vector class within the std namespace. A vector is similar to an array, in a sense where a series of elements are stored with the same variable name. Unlike arrays, vectors are dynamically sized, which is a major advantage.
https://www.geeksforgeeks.org/vector-in-cpp-stl/
+ 4
vectors rcompletely replace dynamic arrays, but you don't have to delete[] anymore.
Very important.