C++ Deque at()C++ Deque at() function is used to access the element at specified position pos. Note: If pos is greater than the size of the container, then the function throws an exception i.e "out of range".SyntaxParameterpos: It defines the position of an element which is to be returned. where, size_type is an unsigned integral type. Return valueIt returns the reference of the specified element. Example 1Let's see a simple example Output: javaTpoint Example 2Let's see a simple example Output: terminate called after throwing an instance of 'std::out_of_range' In this example, at() function tries to access the element which is beyond the size of the container. Therefore, it throws an exception i.e out of range.
Next TopicC++ Deque
|