C++ Deque operator()
C++ Deque operator function is used to access the element at specified position pos. If position pos is greater than the size of container then it returns a value 0.
Difference between operator() & at()
When position pos is greater than the size of the container then operator() function returns a value 0 while at() function throws an exception i.e out of range.
pos: It defines the position of an element which is to be accessed.
It returns a reference to an element at position pos in the deque container.
Let's see a simple example
mango is my favorite fruit
In this example, operator() function access each element of deque a.
Let's see a simple example when pos is out of range.
In this example, operator() function tries to access the position which is greater than the size of the container. Therefore, it returns 0.