[英]Template Fn Pointer error C2146: syntax error : missing ';' before identifier
I am facing a problem with templated member function pointer. 我面临模板成员函数指针的问题。 The code is as shown below.
代码如下所示。
#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) : e:\\ EventHandler.h(13):
error C2146: syntax error : missing ';' before identifier 'm_PtrToCapturer'
I am facing this error. 我正在面对这个错误。
Even If I use 即使我用
method_ptr<EventHandler>::Function m_PtrToCapturer;
as member variable I am getting same error as above. 作为成员变量,我遇到了与上面相同的错误。
I don't know which compiler you use. 我不知道您使用哪个编译器。 I compiled it using GCC.
我使用GCC进行了编译。 It suggests that 'typename' is put before the definition of m_PtrToCapturer.
它建议在“ m_PtrToCapturer”的定义之前放置“ typename”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.