Question

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?

Was it helpful?

Solution 2

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

Thank you anyways!

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top