template的问题
xio 2004-03-20 04:57:34 举例说:
//Plus.h
template <class type>
void Plus(type a1, type a2);
//Plus.cpp
#include "Plus.h"
template <class type>
void Plus(type a1, type a2)
{
cout << "the result is: "<< a1-a2 << endl;
}
//.cpp
void main()
{
int a1=1, a1=3;
Plus(a1, a2);
}
为什么编译不能通过???
如果将函数模板的声明和定义放在同一个文件当中,就没有问题!!!