0

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) :

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.

Chathuranga Chandrasekara
  • 20,548
  • 30
  • 97
  • 138
TechTotie
  • 127
  • 1
  • 15
  • possible duplicate of [Officially, what is typename for?](http://stackoverflow.com/questions/1600936/officially-what-is-typename-for) – Constructor Feb 19 '14 at 19:52
  • Duplicate of http://stackoverflow.com/questions/21863194/solved-templated-function-pointer-in-c/21890444#21890444 – TechTotie Feb 20 '14 at 16:35

1 Answers1

0

I don't know which compiler you use. I compiled it using GCC. It suggests that 'typename' is put before the definition of m_PtrToCapturer.

Tom Weng
  • 19
  • 4