class FIFO private LIFO l1 LIFO l2 public void enqueue int l1 push int

 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
class FIFO
{
private:
LIFO l1;
LIFO l2;
public:
void enqueue(int n)
{
l1.push(n);
}
int isempty()
{
return l1.isempty() && l2.isempty();
}
int dequeue()
{
if (l2.empty())
{
while (!l1.empty())
{
l2.push(l1.pop());
}
}
return l2.pop();
}
};