0% found this document useful (0 votes)
104 views2 pages

Circular Queue Using Node

This C++ program defines classes for patients and queues. The patient class stores patient details like registration number, name, symptoms, and appointment date. The queue class implements a queue using linked nodes, with each node containing a patient object. The queue class methods enqueue and deque add and remove patients from the queue by inserting and outputting patient details. The main function demonstrates adding 3 patients to the queue and then removing them one by one using the queue methods.

Uploaded by

Saif khawaja
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
104 views2 pages

Circular Queue Using Node

This C++ program defines classes for patients and queues. The patient class stores patient details like registration number, name, symptoms, and appointment date. The queue class implements a queue using linked nodes, with each node containing a patient object. The queue class methods enqueue and deque add and remove patients from the queue by inserting and outputting patient details. The main function demonstrates adding 3 patients to the queue and then removing them one by one using the queue methods.

Uploaded by

Saif khawaja
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <iostream> #include<string> using namespace std; class patient { private: int patient_regno; string patient_name; string patient_sympton;

string appoint_date; public: patient() { patient_regno=0; patient_name=""; patient_sympton=""; appoint_date=""; } void insert() { cout<<"PLZ ENTER PATIENT cin>>patient_regno; cout<<"PLZ ENTER PATIENT cin>>patient_name; cout<<"PLZ ENTER PATIENT cin>>patient_sympton; cout<<"PLZ ENTER PATIENT cin>>appoint_date; } void output() { cout<<patient_regno<<endl; cout<<patient_name<<endl; cout<<patient_sympton<<endl; cout<<appoint_date<<endl; }

REGNO #"<<endl; NAME #"<<endl; SYMPTON #"<<endl; APPOINTMENT DATE #"<<endl;

}; class queue { private: struct node { patient s; node *next; }; public: node *ptr,*front; queue() { front=NULL; } node* get_node() { node *p; p=new node(); return p;

} void del_node (node *ptr) { delete ptr; } void enqueue() { ptr = get_node(); ptr->s.insert(); if (front==NULL) front=ptr; else ptr->next = front->next; front->next = ptr; front = ptr; } void deque() { if(front==NULL) { cout<<"QUEUE EMPTY"<<endl; } ptr=front; ptr=front->next; ptr->s.output(); if(ptr==front) front=NULL; else front->next = ptr->next; del_node(ptr); } }; int main() { queue s; s.enqueue(); s.enqueue(); s.enqueue(); s.deque(); s.deque(); s.deque(); return 0; }

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy