0

I'm writing some kind of libary which organizes and keeps track of some tasks. Whenever a nwe task is called my libary uses a function pointer given in the constructor. But when I try to call it I get the error Symbol not found

In the Header file I declared it as:

template <class T>
class TaskManager
{
private:
    // other variables
    T TaskID;  // This is defined like this (just to clear things up)
    void (*TaskHandler)(T, TaskManager<T>*);
    // some more stuff
};

I call it like

template <class T>
void TaskManager<T>::startActualTask()
{
    (*TaskManager<T>::TaskHander)(TaskID, this);    // Errors!
}

or

template <class T>
void TaskManager<T>::startActualTask()
{
    TaskManager<T>::TaskHander(TaskID, this);       // Errors!
}

(Removing TaskManager<T>:: in front of ´TaskHander(TaskID, this);´ did not help.)

But it cannot find the symbol TaskHandler. No matter what i tried so far!

The full error is:

e:\eigene dateien\visual studio 2010\projects\brainstonemod - publish\brainstonemod - publish\TaskManager.cpp(212): error C2039: 'TaskHander': Is no element of 'TaskManager<T>'
          with
          [
              T=int
          ]
          e:\eigene dateien\visual studio 2010\projects\brainstonemod - publish\brainstonemod - publish\TaskManager.cpp(211): At the compiling of the class template of the void TaskManager<T>::startActualTask(void) member function
          with
          [
              T=int
          ]
          e:\eigene dateien\visual studio 2010\projects\brainstonemod - publish\brainstonemod - publish\TaskManager.cpp(73): At the compiling of the class template of the void TaskManager<T>::addTask(Task<T>) member function
          with
          [
              T=int
          ]
          e:\eigene dateien\visual studio 2010\projects\brainstonemod - publish\brainstonemod - publish\TaskManager.cpp(9): At the compiling of the class template of the TaskManager<T>::TaskManager(std::wstring,std::wstring,void (__cdecl *)(T,TaskManager<T> *)) member function
          with
          [
              T=int
          ]
          main.cpp(14): See the Instatiation of the just compiled class template "TaskManager<T>".
          with
          [
              T=int
          ]

(I had to translate this. So it might not be acurate translated!)

This might also be interesting:

template <class T>
TaskManager<T>::TaskManager(wstring title, wstring subtitle, void (*taskHandler)(T, TaskManager<T>*)) :
    // Some intatiations
{
    TaskHandler = taskHandler;
    // More contructor stuff
}

How could i solve this?

8
  • Perhaps it's because you declared it as a non-static private variable?
    – BrainSteel
    Commented Jul 3, 2013 at 16:02
  • I'm calling it in an nonstatic member function. Calling it should not be a problem. The error is, as mentioned above, the compiler cannot find the symbol TaskHandler
    – BrainStone
    Commented Jul 3, 2013 at 16:02
  • Where are you calling it from? Within the TaskManager class?
    – BrainSteel
    Commented Jul 3, 2013 at 16:05
  • Can we get the line of code that triggers the error? Because that code compiles for me.
    – Borgleader
    Commented Jul 3, 2013 at 16:06
  • 3
    I dont know if it is care, but your are calling TaskHander and not TaskHandler is it a typo error?
    – Amadeus
    Commented Jul 3, 2013 at 16:24

2 Answers 2

0

If it's an ordinary member that is a function pointer (which is what it seems to be in your class declaration), you should call it like:

template <class T>
void TaskManager<T>::startActualTask()
{
    TaskHandler(TaskID, this);
}

You only use the TaskManager<T>:: prefix for static members or typedefs.

1
  • 1
    Both should work. And the question says it didn't work either way.
    – aschepler
    Commented Jul 3, 2013 at 16:24
0

It's a typo. I spelled it TaskHander but it's TaskHandler (I forgot the l)

Thank you anyways!

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.