November 1999
Intermediate to advanced
240 pages
5h 22m
English
Difficulty: 5
Only a slight variant—of course, operator=() is still very nifty.
Imagine that the /*????*/ comment in StackImpl stood for public. Implement all the member functions of the following version of Stack, which is to be implemented in terms of StackImpl by using a StackImpl member object.
template <class T>
class Stack
{
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
private:
StackImpl<T> impl_; // private implementation
};
Don't forget exception safety.
This implementation of Stack is only slightly different from ...
Read now
Unlock full access