문제

I am using PC-Lint (great tool for static code analysis - see http://www.gimpel.com/) For the following chunk of code:

class ASD {
    protected:
        template<int N>
        void foo();
};

template<>
inline void ASD::foo<1>() {}

template<int N>
inline void ASD::foo() {}

PC-lint gives me a warning:

inline void ASD::foo<1>() {}
mysqldatabaseupdate.h(7) : Error 1060: protected member 'ASD::foo(void)' is not accessible to non-member non-friend functions

I believe the code is fine and the error is on the lint side, but I think Lint tool is REALLY great tool and it's more likely than I don't know something. So is this code OK?

도움이 되었습니까?

해결책 2

The bug was in PC-Lint itself. It has been fixed in the newest version.

다른 팁

You have only one function foo in your struct ASD and it is in the protected section. It is not accessible from non-member functions. At the same time struct ASD doesn't have any other member functions. So nobody have access to foo, I believe this is the reason for that error message.

Try to change your struct to the following, for example:

class ASD {
    public:
        void bar() { foo<1>(); }
    protected:
        template<int N>
        void foo();
};
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top