#include using namespace std; template Type fun(Type a, Type b){ return a + b; } template T add_n_times(T toadd, int times){ T result = toadd; for(int i = 0; i < times - 1; i++) result = result + toadd; return result; } int main(){ cout << "Adding integers: " << fun(5, 4) << endl; cout << "Adding strings: " << fun("five", "four") << endl; cout << "Adding 7 five times: " << add_n_times(7, 5) << endl; cout << "Adding \"zebra \" 5 times: " << add_n_times("zebra ", 5) << endl; char c_string[] = "cow"; // Can't do this, because C arrays don't have a + operator // cout << "Adding \"cow \" 5 times: " << add_n_times(c_string, 5) << endl; return 0; }