Passing function pointer with scope resolution operator arduino

I'm a newbie to arduino and programming. I've included a library inside my own library in arduino, but first library contains a funtion which has a pointer function as a parameter. It is an interrupt service routine(ISR) but I need to call a function in my cpp file when interrupt is occurred. So I need to pass the pointer of that function to the first library code. It works well when I use it in .ino file, I can pass it like,

attachInterrupt(functionISR_name);

but when I use it in .cpp file, I get errors. my function is like,

void velocity::functionISR_name(){
//some code
}

but how can I pass the pointer of this function to the first library function? I tried this way but got errors,

attachInterrupt(velocity::functionISR_name);

please help!

What errors?

Can you post a complete piece of code that demonstrates this?

yasith1:

attachInterrupt(velocity::functionISR_name);

A gotcha when trying to mix class design with interrupts.

The attachInterrupt function requires the memory address of a function.
velocity::functionISR_name does not resolve to a memory address,
because velocity::functionISR_name refers to the velocity class and not an instance of the velocity class.

You will need to do something like...

//syntax unchecked

velocity myVelocity;
attachInterrupt(myVelocity.functionISR_name);

Not very elegant but the only way I have found.

The attachInterrupt function requires the memory address of a function.
velocity::functionISR_name does not resolve to a memory address,
because velocity::functionISR_name refers to the velocity class and not an instance of the velocity class.

velocity::functionISR_name is perfectly valid input to the attachInterrupt function IF functionISR_name is a static member of the class.

You can NOT tell the attachInterrup function to call a method on an instance of the class. It doesn't know which instance's method to call.