Using a callback function from one class inside another

Hi All.

I'm struggling with using a non static function from one class inside another class. I've been reading some examples, but having a hard time understanding the basics of it. My best try so far, was by using the example given from

I have two classes: ledStrips and MPTimers. MPTimers is a class to use timers on an Atmega. What I want, is to be able to call an instance of MPTimers within ledStrips. In the class of MPTimers, I can attach a callback function, which will be run each time the timer interrupts.

Here's an example of my code, only showing what's relevant.

    MPTimers _timerOne;

    // Constructor
    _timerOne.initialize(1000); // Set up timer with 1000 ms delay
    _timerOne.attachFunction(timeout); // Attach a function to the timer
    _timerOne.stop(); // Stop timer

The timeout function, which is the parameter in .attachFunction, is a member of ledStrips.

This is the code in MPTimers class

    // AttachFunction
    void MPTimers::attachFunction(void (*isr)() )
    isrCallBack = isr;

And the error is: error: no matching function for call to 'MPTimers::attachFunction(unresolved overloaded function type).

I know it's because my instance of MPTimers have no idea to know, which instance the callback function is referering to, because it's a non static member of the class.

I tried the solution as described in the link, but with no succes. Hope that some of you can help me to figure this out :).

I'm struggling with using a non static function from one class inside another class.

Give up now. You can't.

only showing what's relevant.

That's YOUR opinion. We reserve the right to disagree, and we do.

Think about this. When the timer fires an interrupt, it is like ringing a doorbell. Which instance of your class should answer the door?

I guess that's also one way of replying.

But shouldn't it be possible, to change my MPTimers class to accepts functors and then, it should be possible to use it in another class?