April 2000 QUESTION 2 Total Marks: 15 Marks |
Click here to access other
questions
Click to access |
Consider the following definition of a polymorphic Stack (b)Declare a pointer to the Stack class,called x instantiated with
an int type,and show how this could be allocated using the new operator.[2
marks ] (c)Implement the template function Reverse the signature of which
is given below, such that it takes a reference to a stack of type
T and reverses the stack.You may use any of the member functions in
the class Stack necessary. (d)Implement the template function Search the signature of which is given below,such that it takes a reference to a Stack s and an object o and searches the stack for first occurrence of o If found,o should be removed from the stack,leaving the rest of the stack unchanged,otherwise the stack should remain unchanged.You may assume that suitable overloadings of the == operator are available.[5 marks ] |