vector, in C++ can act as a ArrayList, similar to Java or C#. vector itself is included as a part of STL. In this article i just introduce some basic usage of vector, the rest can read here.
Here’s the instantiation of vector:
To add a member, we can use push_back()
vector’s size it very simple to be obtained:
The fun part of using vector when we’re accessing its member, it’s same as we use array :D
To delete a member, it is little different, we should use iterator:
objectList.erase(objectList.begin() + a);
When a is the index of a member we want to delete and objectList.begin() is a method to obtain the initial iterator.