Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7619659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:44:34+00:00 2026-05-31T03:44:34+00:00

So I have a simple struct used for template definitions. template<class T> struct EventListener

  • 0

So I have a simple struct used for template definitions.

    template<class T>
    struct EventListener
    {
        typedef Functor<T, void, Event*> functor;
        typedef void (T::*FunctionPtr)(Event* evt);
    };

and in a class I have a function

    template<class T>
    void addEventListener(const string &eventName, T* target, EventListener<T>::FunctionPtr function);

When I try and build this (VS2010, Windows 7, x64)

I get the following error:

    Error C2061: syntax error : identifier 'FunctionPtr'

I feel like this should be valid.

If I replace the T in the function declaration with a specific class…

    template<class T>
    void addEventListener(const string &eventName, T* target, EventListener<Foobar>::FunctionPtr function);

…The code compiles.

And if I replace the typedef with the actual type…

    template<class T>
    void addEventListener(const string &eventName, T* target, void(T::*function)(Event* evt));

…it also compiles.

So what am I missing here? I am pretty sure that the latter example will suit my purposes, but I would rather keep it in a typedef.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T03:44:36+00:00Added an answer on May 31, 2026 at 3:44 am

    You have to add the typename keyword:

    template<class T>
    void addEventListener(const string &eventName, T* target, 
                          typename EventListener<T>::FunctionPtr function);
    

    otherwise the C++ parser is mandated by the standard to interpret FunctionPtr as a static method, enum, or data-member, etc. in the EventListener namespace, not a typedef.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple struct: typedef struct { void *things; int sizeOfThings; } Demo;
I have a defined a simple template class. In this class I define a
I have a simple c++ struct that is extensively used in a program. Now
I have a struct called Point. Point is pretty simple: struct Point { Row
I have a very simple binary tree structure, something like: struct nmbintree_s { unsigned
We have a class whose semantic behaviour is like the following :- struct Sample
I have a simple template for a combobox structured in this way: <ComboBox DockPanel.Dock=Left
I have a struct that's used in my internet application, which looks like: struct
I have a simple struct Wrapper , distinguished by two templated assignment operator overloads:
I have a function pointer inside a struct that gets dynamically set at runtime

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.