C++: using templates for generics

Example:

template 
T add(T a, T b) {
    return a + b;
}
Templates allow writing generic code.

Solution:

int x = add(2, 3);  // 5
float y = add(2.5f, 3.5f);  // 6.0

Beginner's Guide to C++