我使用的PC - 皮棉的专业化(静态代码分析伟大的工具 - 看到http://www.gimpel.com/) 对于下面的代码块:错误使用C++模板偏
class ASD {
protected:
template<int N>
void foo();
};
template<>
inline void ASD::foo<1>() {}
template<int N>
inline void ASD::foo() {}
PC-lint会给出我一个警告:
inline void ASD::foo<1>() {}
mysqldatabaseupdate.h(7) : Error 1060: protected member 'ASD::foo(void)' is not accessible to non-member non-friend functions
我相信代码是好的,误差在皮棉的一面,但我认为林特工具是真正伟大的工具,它更可能比我不知道的东西。那么这个代码好吗?
但是不会有任意的子类可以访问'foo'函数吗? – 2010-08-18 14:03:31
在这个例子中,我相信产生错误的代码中没有子类。 – 2010-08-18 14:15:23
尝试向该类添加虚拟功能。它可能会在这里做一个权衡。 – 2010-08-18 18:21:23