|If the functions are virtual and I inherit them, wouldn't they save the 'hassle' of including prototypes in every subsequent 'stack','linkedstack','queue','linkedqueue' class?|
But you would have to redefine them all anyway, because they do different things operating on different objects. I know that sounds mad: that is what specialisation is all about. But I can't help thinking you are doing polymorphism here for the sake of it.
With polymorphism, one does try to push variables and functions as high up the inheritance tree as possible, creating a new base class where needed. This has the advantage that functions can take pointers to the base class without having to overload for each and every derived class, thus streamlining the code. I can see this is what you seem to be doing.
The STL seems to avoid that, by using templates and such things as type traits and TMP (Template Meta Programming). For example, the
algorithm arguments are templated iterators and a value.
Also, things like
aren't algorithms, I imagine because they are a function belonging to their individual container class (string, stack, queue etc.) Note that container is a category, not a class.
I had a look at the implementation on my system, there doesn't seem to be a base (container) class for
etcetera. I know the implementation of things is not set in stone, your implementation might be different. But I think the idea will be the same.
Did you Google
? It's a pretty simple concept :+)