码迷,mamicode.com
首页 > 其他好文 > 详细

Template Function

时间:2017-02-15 00:38:30      阅读:105      评论:0      收藏:0      [点我收藏+]

标签:tin   []   continue   blog   .cpp   app   type   nbsp   ica   

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

 

Template Function

标签:tin   []   continue   blog   .cpp   app   type   nbsp   ica   

原文地址:http://www.cnblogs.com/sky20080101/p/6399697.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!