使用<name> = ...不命名类型

Che*_*ron 2 c++ templates using

目标是在模板对象中定义一个函数,其中void(void)作为原型.以下代码:

template <class T>
using ClassVoidFunctionPointer = void (T::*)(void);

class Scheduler {

public:
        Scheduler(void);
        ~Scheduler(void);
        template <class T>
        void addTask(unsigned short interval, unsigned short delay,T templateClass,ClassVoidFunctionPointer classFunctionPtr );//For newer functions
...
}
Run Code Online (Sandbox Code Playgroud)

这给了我错误:

inc/scheduler.h:18:77: error: 'ClassVoidFunctionPointer' is not a type
Run Code Online (Sandbox Code Playgroud)

为什么我会收到此错误?

0x4*_*2D2 5

你忘了模板参数:

, ClassVoidFunctionPointer<T> classFunctionPtr,
Run Code Online (Sandbox Code Playgroud)