Question: Template vs. Inheritance. Why use one over the other?

Solution: Templates are useful when a specific behavior is independent of data type on which it operates.
Whereas inheritance is useful when a)code reuse b)more specifically (as in case of polymorphism) you want to have different specific behavior with a generic name for the behavior.