Advantages of Templates

There are several advantages of templates. They are much easier to use than are the other schemes we have described in this chapter. They are now part of the C++ standard definition, and should be supported by almost all compiler vendors.

On the other hand, the semantics are obscure around the edges, particularly when templates are combined with polymorphic variables. This is perhaps what has delayed the addition of templates to Java. The implementation of templates is very complex. And, when errors are detected in templated functions, the error messages and often be misleading, since they point back to the template class definition, and not where the template is being misused.

[audio] [real] Text to accompany slide17, in Chapter 15 of An Introduction to Object-Oriented Programming