What are the benefits of the templates?

What are the benefits of the templates? Explain briefly.
Let's take a data structure for example. A list will work fine.

Would it be efficient or effective to write dozens of different list classes - one to hold ints, one to hold short ints, one to hold floats, one to hold doubles...and so on, and so forth. Of course not! Plus, if you wanted to put your own classes/structs into this data structure, you'd have to write your own list class. Not very optimal. By using templates, the list class can be written in a general manner that encompasses any and all data types. Now the same class can apply to any data type, including custom, user-designed classes/structs.

The same idea applies to other data structures, functions, etc.
Topic archived. No new replies allowed.