C ++ function pointer with templates

I'm trying to store a pointer to a member function. The class that needs to store the pointer is declared as: template <typename TDataType, typename T> bool my_function(std::string topic_name, void(T::*)(const TDataType&) fp, T* obj) I get the e

Vacuum substitution as a parameter to the model-based method

In my code I have a class which registers method's of other classes: #include <iostream> using namespace std; template< typename C> class Reg { public: template< typename R, typename A> void register_f( string name, R ( C:: *method_p ) (

Function pointer to a model class

I need some help on a strange mix between function pointers and templates... My target : You have a class : template<typename B> class A, and A instanciate a B member. Now I want to acces B getter/setter. I tried this : class B_example { public: B_e

Replace the pointer to member function

I have these two classes: class A { public: A() { m_ptr = NULL; } void (*m_ptr)(); void a() { if (m_ptr) m_ptr(); } }; class B : public A { public: B() { m_ptr = b; } void b() { std::cout << "B::b() is called" << std::endl; } }; And

Pass the member function pointers to the parent class

I'm working on a Pacman game in C++, but have run into a problem with member function pointers. I have 2 classes, pacman and ghost, that both inherit from Mouvement. In the subclasses, I need to pass a function to a function in Mouvement. However, I

Error when using unique_ptr with the member function pointer

I have a class as below class A { public: A(int key) : m_key(key) {} int Key() const {return m_key;} private: int m_key; }; I test using unique_ptr with member function pointer int (A::*MemFun)() const; MemFun = &A::Key; ( std::unique_ptr<A>(new

Unresolved external symbol, with a homemade delegate

I have a function Foo which takes a 2-parameter function as a parameter: void Foo(void (*fcn)(int, int*)); However, the type of function which I want to pass in (func) only takes 1 parameter*. typedef void (__stdcall *FuncCallBack)(int a); void Calle

C ++ class member function and callback from the C API

I am trying to learn how to call this write_data(-) function from the funmain() function in the class as shown in the code bellow. (I know this program works if I just list these two functions without putting it inside a class). curl_easy_setopt(curl

Event Reminder Daemon

I am working on an event daemon in C++ that I would like to use member function callbacks. Basically an event queue would collect events which the daemon continuously services. There is a base class Event struct with an ID and all events would derive

Table of function pointers in a C ++ class

I'm trying to make a table of function pointers within a class. I haven't been able to find any examples of this online, most involve using member function pointers outside of their class. for example: class Test { typedef void (Test::*FunctionType)(

Pass any member function of a class as a callback function

I'm working on a OpenGL menu which contains some buttons. I want to be able to associate an action (member function (with a fixed signature) of any class!) to a button which gets executed when the button is pressed. I can do it right now but only for

Member function pointers in a hierarchy

I'm using a library that defines an interface: template<class desttype> void connect(desttype* pclass, void (desttype::*pmemfun)()); and I have a small hierarchy class base { void foo(); }; class derived: public base { ... }; In a member function of