Some templates, some STL
We have already mentioned the reusability of well-designed, well-implemented C++ code. There is a mechanism which we can only touch (this would be a course by itself), the templates.
- So we have something which sort of manages a collection of “Bodies” for us.
- The next day someone asks if you can make the class deal with “Shapes”. You fire up emacs, replace all “Body” with “Shape”, and you are set.
- The day after someone asks for a vector of “Colors”. You fire up emacs, replace all “Shape” with “Color”, and so on.
- The other week someone asks you to support his own class for “complex” values. At that point you might think that there is a better way of doing that, and indeed there is.