Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Well you just create a vector like vector<type you want> a; then you can put data into it with push_back(data with type you gave before); you can add almost as much data as you want with that method. You can access it like an array a[0] is its first element like in a standard array. Well you also have a size() function which will return its length. For each can be done in multiple ways like with good old array you can go though until size, you can have range fors, and here also iterators. Well if you want one with a given size you can resize(new length) it. You can create multi dimension ones like vector<vector<int>> b; then you can push vector<int> into b the same way.
-
Kodnot4647yGo visit learncpp.com . It's an amazing site that taught me C++ quite well. It's up to date, and it does not contain terrible code samples like many other such sites do.
More importantly for you, I believe it has a pretty good section on std::vector as well ☺
Edit: the exact link: http://learncpp.com/cpp-tutorial/... -
This is the first time I handle std::vector and I'm using orange pi, and I don't really understand how set compiler to c++11, default is c++98.
In c++98 you can't initialize value to vector just like array. Only initialize size and default value. Do I need to pushback manually?
So I change the little library that I found, change it to using double pointer (**) instead. Hha 😌
Yeah, I think it worth to learn it. Thanks guys
Related Rants
-
xjose97x19Just saw a variable in C named like this: long time_ago; //in a galaxy far away I laughed no stop.
-
Unskipp24So this happened last night... Gf: my favorite bra is not fitting me anymore Me: get a new one ? Gf: but it ...
-
sam966911Hats off to this lady .... I would have just flipped the machine
Getting hard time to understand std::vector and even more confusing with multidimensional vector.
Going back to array. 😪
rant
std::vector
c++