Where are the objects in the vector highlighted? a bunch?
It depends on the STL implementation, but in all likelihood on the heap yes.
does vector have boundary check? If the index out of the boundary, what error will happen?
Yes, the vector is growing dynamically, you can check its size using the member function capacity() . If it should end, it usually allocates more space using the reserve() member function.
Why is an array faster than a vector?
Arrays can be faster because this is simple data that does not need to be accessed through a wrapper, such as vector. . For convenience, you can use vector as a neatly packed array.
Is there a case where a vector is not applicable, but an array is required?
I think there may be times when an array is preferable over a vector . For example, when you are dealing with legacy C code, or when speed is paramount. But usually you can solve any problem with the array by specifying the data in STL vector .
source share