有模板类List。
template <typename Point>
class List
{
public:
template <const unsigned short N>
void load ( const char *file);
...
};
template <typename Point>
template <const unsigned short N>
void List <Point>::load ( const char *file)
}
如何专门化 N=2 的方法负载?此代码无效...
template <typename Point>
void List <Point> <2>::load ( const char *file)
{
}
而且这段代码也不起作用。
template <typename Point>
void List <Point> ::load <2> ( const char *file )
{
}
Error 3 error C2768: 'List<Point>::load' : illegal use of explicit template arguments 66.
Error 5 error C2244: 'List<Point>::load' : unable to match function definition to an existing declaration 66
编译器 g++:
template <typename Point>
template <>
void List <Point> ::load <2> ( const char *file )
{
}
error: explicit specialization in non-namespace scope `class List<>'
error: enclosing class templates are not explicitly specialized
error: default arguments are only permitted for function parameters
error: `load' is not a function template
error: invalid function declaration