编译环境VC6创天中文版
#include <iostream>
#include <string>
class TestA
{
public:
template<class T>
int compare(const T& a, const T& b)
{
if(a < b)
return -1;
else
return 0;
}
};
void main(void)
{
TestA a;
a.compare<int>(1, 2);
a.compare<std::string>("abc", "cde");
}
--------------------Configuration: learn - Win32 Debug--------------------
Compiling...
learn.cpp
E:/devdir/learn/learn.cpp(19) : error C2062: type 'int' unexpected
E:/devdir/learn/learn.cpp(20) : error C2275: 'std::string' : illegal use of this type as an expression
Error executing cl.exe.
learn.exe - 2 error(s), 0 warning(s)