+ 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.

10th Apr 2018, 2:46 AM
Naman Bhawsar
Naman Bhawsar - avatar
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!
10th Apr 2018, 11:14 AM
AZTECCO
AZTECCO - avatar
10th Apr 2018, 9:33 AM
Hatsy Rei
Hatsy Rei - avatar
+ 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/
10th Apr 2018, 3:02 AM
📈SmileGoodHope📈
📈SmileGoodHope📈 - avatar
+ 4
vectors rcompletely replace dynamic arrays, but you don't have to delete[] anymore. Very important.
10th Apr 2018, 1:40 PM
Timon Paßlick