Chinaunix首页 | 论坛 | 博客
  • 博客访问: 94308
  • 博文数量: 50
  • 博客积分: 1086
  • 博客等级: 少尉
  • 技术积分: 420
  • 用 户 组: 普通用户
  • 注册时间: 2011-10-25 16:16
文章分类
文章存档

2011年(50)

我的朋友

分类: C/C++

2011-11-15 19:53:52

  1. queue member functions


  2. #include "stdafx.h"
  3. #include "stdlib.h"
  4. #include <stdio.h>
  5. #include <iostream>
  6. #include <queue>
  7. #include <vector>
  8. #include <list>




  9. void main()
  10. {
  11. using namespace std;
  12. // Declares queue with default deque base container
  13. // queue <char> q1;
  14. //
  15. // // Explicitly declares a queue with deque base container
  16. // queue <char, deque<char> > q2;
  17. //
  18. // // These lines don't cause an error, even though they
  19. // // declares a queue with a vector base container
  20. // queue <int, vector<int> > q3;
  21. // q3.push( 10 );
  22. // // but the following would cause an error because vector has
  23. // // no pop_front member function
  24. // // q3.pop( );
  25. //
  26. // // Declares a queue with list base container
  27. // queue <int, list<int> > q4;


  28. // The second member function copies elements from a container
  29. list<int> li1;
  30. li1.push_back( 1 );
  31. li1.push_back( 2 );
  32. queue <int, list<int> > q5( li1 );
  33. cout << "The element at the front of queue q5 is "
  34. << q5.front( ) << "." << endl;
  35. cout << "The element at the back of queue q5 is "
  36. << q5.back( ) << "." << endl;






  37. system("Pause");
  38. }
阅读(1118) | 评论(0) | 转发(0) |
0

上一篇:临界区算法 Peterson

下一篇:Linux方面书籍

给主人留下些什么吧!~~