From the course: C++ Standard Template Library

Unlock the full course today

Join today to access over 22,700 courses taught by industry experts or purchase this course individually.

Solution: Stack/queue application

Solution: Stack/queue application - C++ Tutorial

From the course: C++ Standard Template Library

Start my 1-month free trial

Solution: Stack/queue application

(light notes ringing) - [Instructor] Here is my solution. We'll start by adding a new stack because we need to keep track of the forward history. And so, we will do this at line 12. We'll call it forward stack, fwd_stack. The next change will be in the menu. We have to add the forward option. It will be a third option. This goes in line 16. And the case for the exit option will stay the same, but we have to change something for option number one which is when we visit a new URL. This change consists on emptying the forward stack. I will do that by creating a new object in line 24. We can do this by calling the constructor of the stack class. Now, in option two, we have to push the current address into the forward stack. We have to do that right before the pop operation. This will happen in line 28. We will do this by calling the push function in forward stack. And we will pass the top of the back stack to it. Now we are ready to implement option number three. I will do that in line…

Contents