Template Function

// 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

 

posted @ 2017-02-14 23:43  sky20080101  阅读(133)  评论(0编辑  收藏  举报