目标是在模板对象中定义一个以 void (void) 为原型(prototype)的函数。 代码如下:
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
...
}
这给了我错误:
inc/scheduler.h:18:77: error: 'ClassVoidFunctionPointer' is not a type
为什么我会收到此错误?
最佳答案
您忘记了模板参数:
, ClassVoidFunctionPointer<T> classFunctionPtr,
关于c++ - 使用 <name> = ... 不命名类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20048150/