How do libraries attach interrupts referencing its own functions

Hello i am creating a library and would need to use interrupts in the class. usually what happens when i use an interrupt is i set it up in the void setup and just simply reference the function. but i do not know how to do it if its inside the class.

Here is a code of somewhat what i want (of course this throws an error)

class counter{
  public:
  
  void startCounting(){
    attachInterrupt(digitalPinToInterrupt(4),this.addCount,CHANGE);
  }
  void stopCounting(){
    detachInterrupt(digitalPinToInterrupt(4));
  }

  void addCount(){
    count++;
  }
  
  private:
  
  unsigned long count= 0;
};

i do not know how to write the ISR parameter

Will you instantiate multiple counter objects?

aarg:
Will you instantiate multiple counter objects?

yes but it will most likely use another pin for the interrupt

Then you have to have static enumeration of timers in your class.

aarg:
Then you have to have static enumeration of timers in your class.

I apologize i dont quite follow what you mean by enum of timers, searching also did not yeild some relevant results

I have adjusted the code to accomodate settable pins to interrupt (if that matters)

class counter{
  public:
  counter(int pin){
    Ipin=pin;
  }
  void startCounting(){
    attachInterrupt(digitalPinToInterrupt(Ipin),this.addCount,CHANGE);
  }
  void stopCounting(){
    detachInterrupt(digitalPinToInterrupt(Ipin));
  }

  void addCount(){
    count++;
  }
  
  private:
  int Ipin;
  unsigned long count= 0;
};

As far as i know you cant place static on enums but there is a way around it

enum letters{a,b,c,d};
static letters x ;

but i could not see how i can apply it so that i can attach the ISR parameter to the function inside the class

Non-static class instance functions have a different signature than regular or static functions. Thus, their pointers are of an incompatible type to functions like attachInterrupt(). Here's a good reference: Standard C++

John41234:
I apologize i dont quite follow what you mean by enum of timers, searching also did not yeild some relevant results

Sorry about the terminology, I meant enumeration generally, not the C 'enum'. I mean that you will have to have a static record in your class, of which timers have been allocated by previous instantiations of the class. Static variables in a class, are shared between all instantiations.

Seems that its too difficult for me to understand. Do you think you can give me an example using my sample code?