   what good are templates? what do they do?
  I think the only thing built into C++ that I havne't bothered to learn is templates. From what I've read it's basically a way to make your own types, like Integers or doubles, or am I reading it wrong.1: How are they used for app or game purposes?2: What exactly makes them useful?   
Template meta-programming.The simplest explanation would be that it is functional programming, evaluated completely at compile-time. Since it represents different paradigm than that of C++, the concepts may be somewhat hard to grasp at first.Take a linked list. Templates allow single implementation to hold any type - but all error checking is done by compiler during compilation. In C, such checks would be done during run-time, if they were even detected. Templates allow development of generic algorithms.Next step is they can be used to abstract algorithms. STL is good example, where not only can any element be stored in list, algorithms that manipulate them can operate on any container. Again, all checked by compiler during compile time.And since compilers knows everything, it can make informed choices about how to generate code. It can choose to evaluate entire algorithm during compilation, to remove unused code, to either re-use already generated code or generate one for each version of algorithm.Once mastered, they can be incredibly powerful tool, but they come with many pitfalls (especially in C++), such as potential code bloat, excessive compile times and not entirely standardized support by compiler vendors.Boost library is an example of hard-core template programming.   ;  they are a way of creating 'generic' classes and/or structures, consider the following://header:template <class T>class IDAndType{public:    IDAndType(unsigned int nID, T value);    unsigned int GetID();    T GetValue();protected:    unsigned int m_nID;    T m_value;};//implementation:template<class T>IDAndType::IDAndType(unsigned int nID, T value): m_nID(nID), m_value(value){    //the initialization in the constructor assumes    //the type has a const reference constructor}template<class T>unsigned int IDAndType::GetID(){    return m_nID;}template <class T>T IDAndType::GetValue(){    return m_value;}So right now, you have a generic class, that can hold any type and a identifier of some sort. This way you don't have to create 5 classes if you wanted a float, integer, unsigned integer, short and a unsigned short with an identifier. Now you can do the following:IDAndType<unsigned int> foo(/*ID*/5, /*value*/24560);IDAndType<float> bar(20, 5.0f);//or even the followingclass Spaceship {public:    float fHealth;    float fMaxSpeed;};Spaceship spacebandit;spacebandit.fHealth = 100.0f;spacebandit.fMaxSpeed = 25.5f;IDAndType<Spaceship> IDSpaceship(25, spacebandit);;  They're not a way to 'make your own types.' That's what classes are for :)A simple example of templates is std::vector. If you've never seen it, check it out. It's basically a non-fixed-size array that can hold objects of any type. It uses templates; you create one by specifying the type of object it will hold in its template argument, like so: std::vector<int> myVector. The beauty of it is that vectors (and any other templated object) can deal with any type, standard or user-defined, with minimal extra work from the programmer.   ;  One use of templates is that you can write generic functions that can work against multiple types of data.  For example you can write a sort function that works with ints, floats, and even specific classes you've made (assuming you overload the > and < operators for your class).