+1 vote
in C Plus Plus by

 How to get element by index in vector | at() vs operator []

1 Answer

0 votes
by

std::vector provides [] operator i.e.

1

element_reference operator[] (size_type n);

It returns the reference of element in vector at index n.

std::vector provides an another member function at() i.e.

reference at(size_type n);

It returns the reference of element at index n in vector. If index n is out of range i.e. greater then size of vector then it will throw out_of_range exception.

...