Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/131.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 模板Fn指针错误C2146:语法错误:缺少'';前标识符_C++_Templates_Function Pointers_Member Function Pointers_Member Variables - Fatal编程技术网

C++ 模板Fn指针错误C2146:语法错误:缺少'';前标识符

C++ 模板Fn指针错误C2146:语法错误:缺少'';前标识符,c++,templates,function-pointers,member-function-pointers,member-variables,C++,Templates,Function Pointers,Member Function Pointers,Member Variables,我面临模板成员函数指针的问题。代码如下所示 #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&g

我面临模板成员函数指针的问题。代码如下所示

#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;
};
我面临着这个错误

即使我使用

method_ptr<EventHandler>::Function m_PtrToCapturer;
method_ptr::函数m_PtrToCapturer;

作为成员变量,我得到了与上面相同的错误。

我不知道您使用的是哪种编译器。我使用GCC编译了它。它建议将“typename”放在m_PtrToCapturer的定义之前。

可能重复的
method_ptr<EventHandler>::Function m_PtrToCapturer;