If front() returns a reference and the container is empty what do I get, an undefined reference? Does it mean I need to check empty() before each
front()
empty()
Yes, you can use 'at' like Graham mentioned instead of using front.
But, at(0) is only available for some containers - vectors, deque and not for others - list, queue, stack. In these cases you've to fall back on the safety of the 'empty' check.