I am learning queues and I have found 2 examples. Both examples represent queues with limited size, for example 30.
But <queue> allows us to create queue that is not limited by *pre-set queue size.

Can anyone explain me how have they created something like that?


By *pre-set I wanted to say that we have set the queue size during its initialization. Like when we create the arrays.

The default back-end for std::queue is std::deque, which grows and shrinks dynamically. std::queue is actually a form of adapter that sits on top of a data structure to provide a convenient interface. std::stack is the same way.

std::deque is implemented in a somewhat confusing way, so you might consider studying how std::vector works intead (it's basically a dynamic array). It grows dynamically as well, but in a much more intuitive manner. That should get you rolling on answering the question: "how have they created something like that?". :)