Im making a class for my encoder that uses interrupts and in begin() function i need it to attach to a function of the class. but it throws me an error
error: invalid use of non-static member function 'void ENCODER::recordTime()'
What makes You think You should use class?
Interrupt is a hardware dependant function. You can't "class", like clone, one piece of hardware inte several instances.
although true that you cant clone one piece hardware to several instance, it is possible to pass a pointer to the class , just like how you can pass the SPI or Wire pointer to multiple class instance.
but im not sure though that attachInterrupt is a class or just an ordinary function
Think about it for a moment.
A class is designed to have multiple instances.
But an interrupt is bound to a single hardware resource.
If you had an ISR that was a class member, then every instance of the class would contend for the same hardware resource.
That's not necessarily true. Consider multiple sensors, all tied to the same external interrupt signal with a big "or" gate. However, ISRs are pure C functions, and do not know how to set up "this" for calling a class function.
b707's suggestion of an intermediate non-class function is the way to go.
You can look at the way Serial is handled in the core (on boards with multiple serial ports, like a Zero or Nano Every), for an example.
I meant it in the sense of "it's bound to a single processor hardware resource" - like a falling or rising edge on a particular pin, or a receiver register full condition