You are on page 1of 1

Object Oriented Programming

Lab 11
Topic Covered: Inheritance FIFO (First In First Out)

Q1A. Create a class named fifo.


1. It has three attributes as protected
 st as int array of size MAX=5.
 top as int
 tail as int
2. Make no argument constructor to set top and tail
equals to -1.
3. Make void push(int var) function to insert data into
top of the fifo and write cout<<“Push = ”<<var<<endl.
4. Make int pop() function to remove data from the tail
of the fifo.
Q1B. Create another class named fifo2 that is publicly
inherited from fifo class.
1. Make void push(int var) function to insert data into
fifo and check the full condition before inserting.
 If the fifo is full then display the “Fifo Full”
message otherwise call void push(int var) function
of parent class from child class.
2. Make int pop() function to remove value from the fifo
and check the empty condition before removing.
 If the fifo is empty then display the “Fifo
Empty” message and return -1 otherwise call int
pop() function of parent class from child class.
 Also set the top and tail to -1 when both become
equal
Q1C. Make main() function
Make a fifo2 object. Call the functions in following order
 push, push, push, push, push, push, pop, pop,
pop, pop, pop, pop, push, push, pop, pop and show
information on screen.

You might also like