Advertisement
Guest User

list.h

a guest
Nov 5th, 2012
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #ifndef LIST_H
  2. #define LIST_H
  3.  
  4. #include "stdafx.h"
  5.  
  6. template<class T> class Node
  7. {
  8. public:
  9. Node(T data) { entry = data; }
  10. T entry;
  11. Node * next;
  12. };
  13.  
  14. template<class T> class List
  15. {
  16. Node<T> * head;
  17. Node<T> * tail;
  18. size_t length;
  19. public:
  20. List() { head = NULL; tail = NULL; length = 0; }
  21. void push_front(T);
  22. T pop_front();
  23. void push_back(T);
  24. T pop_back();
  25. };
  26.  
  27. template<class T> class Stack
  28. {
  29. List<T> list;
  30. public:
  31. void push_front(T);
  32. T pop_front();
  33. };
  34.  
  35. template<class T> class Queue
  36. {
  37. List<T> list;
  38. public:
  39. void push_back(T);
  40. T pop_back();
  41. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement