O'Reilly logo

Mastering C++ Programming by Jeganathan Swaminathan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Commonly used vector APIs

The following table shows some commonly used vector APIs:

API

Description

at ( int index )

This returns the value stored at the indexed position. It throws the std::out_of_range exception if the index is invalid.

operator [ int index ]

This returns the value stored at the indexed position. It is faster than at( int index ), since no bounds checking is performed by this function.

front()

This returns the first value stored in the vector.

back() 

This returns the last value stored in the vector.

empty()

This returns true if the vector is empty, and false otherwise.

size() 

This returns the number of values stored in the vector.

reserve( int size ) 

This reserves the initial ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required