I learned in my college DSA course that a stack is initialized with a capacity that limits the number of elements it can contain. But when I create a stack using the STL, you don't have to define a capacity. Is there a capacity involved, or does it not apply in the STL implementation? Do stacks even really need a capacity?
The stack implementation you looked at in your course may have had a limit, but that's not essential to being a stack. (And your course really should have taught you this.)
The C++ standard library stack is just an adapter for any underlying collection that supports the necessary operations, so whether it has a limited capacity or not depends on that underlying type.
(The default is std::deque
.)