【发布时间】:2010-12-28 01:01:10
【问题描述】:
我有一个带有函数模板的基类。
我从基类派生并尝试对派生类中的函数模板进行专门化
我做了这样的事情。
class Base
{
..
template <typename T>
fun (T arg) { ... }
};
class Derived : public Base
{
...
} ;
template <>
Derived::fun(int arg);
在 .cpp 文件中,我提供了模板专业化的实现。
这适用于 MSVC 8.0,g++-4.4.2 抱怨 Derived 类中缺少函数声明乐趣。
我不知道哪个编译器的行为正确。非常感谢您提供任何帮助。
提前致谢, 苏里亚
【问题讨论】:
标签: c++ inheritance templates