-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueueImplementation.cpp
More file actions
71 lines (55 loc) · 1.04 KB
/
QueueImplementation.cpp
File metadata and controls
71 lines (55 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include<bits/stdc++.h>
using namespace std;
class Person{
private:
string name;
int id;
public:
Person(string name, int id)
{
this->name = name;
this->id = id;
}
string getName(){
return this->name;
}
int getID(){
return this->id;
}
void printInfo(){
cout << "{Name : " << this->name << " | ID : " << this->id << "}";
}
};
struct Node{
Person data;
struct Node *next;
};
Node *front = NULL, *back = NULL;
void queuePerson(Person person){
struct Node *n;
n->data = person;
n->next = NULL;
if(front = NULL){
front = back = n;
return;
}
back->next = n;
back = n;
}
void printQueue(){
Node *p = front;
while(p){
p->data.printInfo();
cout << " -> ";
p = p->next;
}
cout << "\n";
}
int main()
{
queuePerson(Person("Jishan", 1000));
queuePerson(Person("Jishan", 1000));
queuePerson(Person("Jishan", 1000));
queuePerson(Person("Jishan", 1000));
printQueue();
}