Vectors v/s arrays

Can any one explain me the difference between the vectors and arrays, like how to access and store the values in them.
For arrays, any basic C or C++ tutorial should cover what you need.

For vectors, look at the reference material on this very site, e.g.

http://www.cplusplus.com/reference/vector/
You can access and store values the same way in both containers. Just std::vector gives you more options to do so, is much safer and dynamically sized (can store an unspecified, growing number of objects).
closed account (zb0S216C)
As ResidentBiscuit said, accessing a "std::vector" and an array is identical when the sub-script operator is used. Accessing a "std::vector" and an array with the sub-script operator never explicitly throw exceptions unless the OS believes you're accessing unowned memory.

Microsoft's & GNU's implementation of "std::vector::operator[]( )" never throw exceptions, nor do they check if the index is out-of-range.

Wazzak
thank you all
Framework wrote:
Microsoft's & GNU's implementation of "std::vector::operator[]( )" never throw exceptions, nor do they check if the index is out-of-range.

You can make GCC check this by defining the the macro _GLIBCXX_DEBUG when compiling your program. It will print an error message and terminate the program.
> Microsoft's & GNU's implementation of "std::vector::operator[]( )" never throw exceptions,
> nor do they check if the index is out-of-range.

std::vectir<>::at() would become redundant if std::vecto<>r::operator[]( ) also provided for bounds-checked access.
Both std::vector<>, and std::deque<> leave that decision to the programmer who uses the container.
Topic archived. No new replies allowed.