December
1999 QUESTION 2 Total Marks: 15 Marks |
Click here to access other
questions
Click to access |
|
|||||||||||||||||||||||||||||
(a) |
Template classes are an example of polymorphism .Explain what is meant by polymorphism .
|
[2] | |||||||||||||||||||||||||||
(b) |
Declare a pointer to an object of type Queue ,with an integer template type.
|
[1] | |||||||||||||||||||||||||||
(c) |
Show how this object can be allocated using the new operator.
|
[1] | |||||||||||||||||||||||||||
(d) |
Write a polymorphic iterative function,called RemoveItemN ,the signature of which is given below,which takes a reference to a queue Q and an integer x ,and will remove and return the x ’th item from the queue Q .The rest of the queue should remain unchanged.You should assume that counting queue elements starts at zero,and you may use the functions which have been declared in the class Queue . template <class T>
|
[6] | |||||||||||||||||||||||||||
(e) |
Write a polymorphic recursive function,called Reverse ,the signature of which is given below,which takes a reference to a queue Q and reverses the queue.To reverse a queue,items should be recursively removed from the queue,and then added to the queue as the recursive stack is unwound.You may use the functions which have been declared in the class Queue . template <class T> |
[5] |