我有

template < typename threadFuncParamT >
class ThreadWrapper
{
public:
    static int ThreadRoutineFunction(void* pParam);
    int ExecuteThread();

    ThreadWrapper(ThreadPool<threadFuncParamT> *pPool);

};

template<typename threadFuncParamT>
int ThreadWrapper<threadFuncParamT>::ThreadRoutineFunction(void* pParam)
{
    ThreadWrapper<threadFuncParamT> *pWrapper = reinterpret_cast<ThreadWrapper<threadFuncParamT>*>(pParam);
        if(pWrapper != NULL)
{

        return pWrapper-ExecuteThread(); // Error here.
    }

    return 0;
}

template < typename threadFuncParamT >
ThreadWrapper<threadFuncParamT>::ThreadWrapper(ThreadPool<threadFuncParamT> *pPool)
{
    ThreadWrapper<threadFuncParamT>::m_pThreadPool = pPool;
    m_tbbThread = new tbb::tbb_thread(&(ThreadWrapper<threadFuncParamT>::ThreadRoutineFunction), this);
    if (m_tbbThread->native_handle() == 0)
    {
        delete m_tbbThread;
        m_tbbThread = NULL;
        // TODO: throw execption here or raise assert.
    }
}


我收到如下错误
错误1错误C2352:“ ThreadWrapper :: ExecuteThread”:非法调用非静态成员函数

我正在VS2010上编译。

任何人都可以帮助我在这里如何清除错误。

谢谢!

最佳答案

您缺少“>”
它的

pWrapper->ExecuteThread()




pWrapper-ExecuteThread()

关于c++ - 使用模板的C++静态编译错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6941478/

10-11 15:38