Linking 错误
#include <iostream>
using namespace std ;
template<class T>
T TMax(T a, T b) ;
int main(void)
{
cout << TMax(2.3,6.3) << endl ;
cout << TMax(2,6) << endl ;
cin.get() ;
return 0 ;
}
double mass(double density, double volume = 1.0)
{
return density * volume ;
}
void repeat(int n, char *str)
{
for(int i = 0; i < n ; i++)
{
cout << str ;
}
}
void repeat(char *str)
{
repeat(10, str) ;
}
double average(double a, double b)
{
return (a + b) / 2 ;
}
int average(int a, int b)
{
return (a + b) / 2 ;
}
char mangle(char a)
{
return 'I' ;
}
char *mangle(char *a)
{
return a ;
}
template<class T>
T TMax(T a, T b)
{
return a < b? b: a ;
}
——————————————————————————————
在vc6种编译是错误:
--------------------Configuration: Ex8_5 - Win32 Debug--------------------
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/Ex8_5.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Ex8_5.exe - 2 error(s), 0 warning(s)
——————————————————————-----------------------------
前问这是怎么回事?谢谢。