首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

有关模板有关问题

2012-02-25 
有关模板问题#includestdafx.h #includeiostreamusingnamespacestdtemplatetypenamemyTypemyTypema

有关模板问题
#include   "stdafx.h "
#include   <iostream>


using   namespace   std;

template   <typename   myType>
myType   max(myType   a,myType   b)
{
return   a;
}


int   _tmain(int   argc,   _TCHAR*   argv[])
{
int   a=1,b=2;
cout   < <   "1,2: "   < <   max(a,b)   < <   endl;
return   0;
}

为什么这个程序编译不过,奇怪啊。谁帮看看,谢谢

[解决办法]
myType max(myType a,myType b)
{
return a;
}
===============================
myType max(myType& a,myType& b)
{
return a;
}
[解决办法]
不要用min/max,和系统自带的重名了。

热点排行