类函数模板的使用问题

编译环境VC6创天中文版

#include
#include
class TestA
{
    public:
    template
    int compare(const T& a, const T& b)
    {
        if(a < b)
            return -1;
        else
            return 0;
    }
};

void main(void)
{
 TestA a;
 a.compare(1, 2);
 a.compare("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)
 

你可能感兴趣的:(类函数模板的使用问题)