Wednesday, June 22, 2005

Stacks and Vectors

Inspired by my friend Balbir, I've decided to start posting technical questions on my blog. Here is the first one:

You want to implement a Stack using a Vector. So, how do you do it? There are three approaches (in C++):

1) class Stack : public Vector
2) class Stack : private Vector
3) class Stack
Vector vec;

Of the three, which is the best, and which is the worst, and why?
No prizes for guessing which method Java adopts...

No comments: