November 1999
Intermediate to advanced
240 pages
5h 22m
English
Difficulty: 9
And now for an even better Stack, with fewer requirements on T—not to mention a very elegant operator=().
Imagine that the /*????*/ comment in StackImpl stood for protected. Implement all the member functions of the following version of Stack, which is to be implemented in terms of StackImpl by using StackImpl as a private base class.
template <class T>
class Stack : private StackImpl<T>
{
public:
Stack(size_t size=0);
~Stack();
Stack(const Stack&);
Stack& operator=(const Stack&);
size_t Count() const;
void Push(const T&);
T& Top(); // if empty, throws exception
void Pop(); // if empty, throws exception
};
As always, remember to make all the functions exception-safe and exception-neutral. ...
Read now
Unlock full access