//============================================================== // Templates - Wzorce;
// function template (2) //
// ver data temat autor // 100 2010/11/14 Pierwszy projekt J.Malinowski // 101 2015/10/03 Cleanup JM // 102 2019/12/16 Cleanup JM //============================================================== #include <conio.h> #include <iostream> using namespace std; //---template <class T, class U>
T GetMin (T a, U b) {
// return (a<b) ? a : b; // wskazana jawna konwersja typu; return (a<b) ? a : static_cast<T>(b);
}
//============================================================== int main(int argc, char* argv[])
{
int i,j=5; long l=4;
double x=3.5,y,v,z;
// function_name <type1,type2> (parameters); i = GetMin<int,long> (j,l); y = GetMin<int,double> (j,x); v = GetMin<double,int> (x,j); z = GetMin<double,int> (x,j); cout << i << endl; cout << y << endl; cout << v << endl; cout << z << endl; getch(); return 0; } //==============================================================