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