Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- struct Node
- {
- int value;
- Node* next;
- Node()
- {
- value=0;
- next=nullptr;
- }
- Node(int _value,Node* _next)
- {
- this->value=value;
- this->next=_next;
- }
- };
- class Queue
- {
- private:
- Node* head,tail;
- int size;
- public:
- Queue()
- {
- head=nullptr;
- tail=nullptr;
- size=0;
- }
- void pop_front()
- {
- if(head==nullptr&&tail==nullptr) return;
- Node* temp=head->next;
- delete head;
- head=tmp;
- size--;
- }
- void push_back(int value)
- {
- if(head==nullptr&&tail==nullptr)
- {
- Node* temp=new Node(value,nullptr);
- head=temp;
- tail=temp;
- temp=nullptr;
- }
- Node* temp=new Node(value,nullptr);
- tail->next=temp;
- tail=temp;
- temp=nullptr;
- size++;
- }
- };
- int main () {
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement