// TemplateFunction.cpp : Defines the entry point for the console application. // #include "stdafx.h" template<typename T> T MyMax(T a,T b) { return a>b ? a : b; } int main(int argc, char* argv[]) { int i=MyMax<int>(1,3); int j=MyMax(1,0); printf("%d\n%d\n",i,j); return 0; } // 3 // 1 // Press any key to continue
时间: 2024-10-26 17:41:02