AUtils.h
内容:class AUtils {
public:
template<class T> static T max (T a, T b) ;
} ;template<class T>
T AUtils::max (T a, T b)
{
if (a > b) {
return a ;
}
else {
return b ;
}
}在main.cpp中调用#include "stdafx.h"
#include "AUtils.h"int main(int argc, char* argv[])
{
int a = AUtils::max<int> (1, 8))
printf("Hello World!\n");
return 0;
}
报错
fatal error C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 1786)
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
内容:class AUtils {
public:
template<class T> static T max (T a, T b) ;
} ;template<class T>
T AUtils::max (T a, T b)
{
if (a > b) {
return a ;
}
else {
return b ;
}
}在main.cpp中调用#include "stdafx.h"
#include "AUtils.h"int main(int argc, char* argv[])
{
int a = AUtils::max<int> (1, 8))
printf("Hello World!\n");
return 0;
}
报错
fatal error C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 1786)
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
#include <iostream>
using namespace std;
template<class T>
class AUtils
{
public:
static T max (T a, T b) ;
} ; template <class T>
T AUtils<T>::max (T a, T b)
{
if (a > b)
{
return a ;
}
else
{
return b ;
}
}
int main(int argc, char* argv[])
{ int a=AUtils<int>::max(1,8);
printf("Hello World!\n");
return 0;
}