Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. struct Node
  4. {
  5. int value;
  6. Node* next;
  7. Node()
  8. {
  9. value=0;
  10. next=nullptr;
  11. }
  12. Node(int _value,Node* _next)
  13. {
  14. this->value=value;
  15. this->next=_next;
  16. }
  17. };
  18. class Queue
  19. {
  20. private:
  21. Node* head,tail;
  22. int size;
  23. public:
  24. Queue()
  25. {
  26. head=nullptr;
  27. tail=nullptr;
  28. size=0;
  29. }
  30. void pop_front()
  31. {
  32. if(head==nullptr&&tail==nullptr) return;
  33. Node* temp=head->next;
  34. delete head;
  35. head=tmp;
  36. size--;
  37. }
  38. void push_back(int value)
  39. {
  40. if(head==nullptr&&tail==nullptr)
  41. {
  42. Node* temp=new Node(value,nullptr);
  43. head=temp;
  44. tail=temp;
  45. temp=nullptr;
  46. }
  47. Node* temp=new Node(value,nullptr);
  48. tail->next=temp;
  49. tail=temp;
  50. temp=nullptr;
  51. size++;
  52. }
  53. };
  54. int main () {
  55. return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement