课程: C++ Standard Template Library
今天就学习课程吧!
今天就开通帐号,24,100 门业界名师课程任您挑!
Queues
- [Lecturer] Now, let's talk about the queue container adapter. Since the stack and the queue container adapters are so similar, let me show you how to convert the code of the stack we have just written into the functionality of a queue. So I will change some lines of code right now. Let me change this first comment to queue, and in line number five, I will change the header file to the header file named queue. The next thing we need to change is in line number ten, where we originally declared the stack. Now, we will change this to a queue. Everything else can stay the same in the pushing round of insertions. That is because a queue has the same push function we can see here at line 18. As for the printing part of the code, here's what we'll change. Line number 23 is referring to the top function, but a queue does not have a top, queues have front, and so, this is just a semantic issue, but we have to change this to front, which is where the elements come out of a queue. And there…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。