// console_templates.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include using namespace std; template T absol(T x) { //obecne pouzijeme parametr T, jehoz typ se urci volanim funkce if(x<0) return -x; return x; }; int _tmain(int argc, _TCHAR* argv[]) { int a,b = -5; double x, y = -7.13; a = absol(b); // vznikne int absol(int), výsledek 5 cout << a << endl; x = absol(y); // vznikne double absol(double), výsledek 7.13 cout << x << endl; return 0; }