0
我面临模板成员函数指针的问题。代码如下所示。模板Fn指针错误C2146:语法错误:缺少';'之前标识符
#include <String>
#include <iostream>
template<typename T>
struct method_ptr
{
typedef void (T::*Function)(std::string&);
};
template <class T>
class EventHandler
{
private:
method_ptr<T>::Function m_PtrToCapturer;
};
E:\ EventHandler.h(13):
error C2146: syntax error : missing ';' before identifier 'm_PtrToCapturer'
我面对这个错误。
即使我使用
method_ptr<EventHandler>::Function m_PtrToCapturer;
为成员变量我如上得到同样的错误。
可能的重复[正式,什么是typename?](http://stackoverflow.com/questions/1600936/officially-what-is-typename-for) – Constructor
重复的http://stackoverflow.com/questions/21863194/resolved-templated-function-pointer-in-c/21890444#21890444 – TechTotie