A static variable means static per instance.
No. A static variable, or function, is owned by the class, not any instance of the class.
A variable available throughout my entire class is not called global.
If a variable is static, it is owned by the class, not an instance of the class. If the variable is in the class, but is not static, is it cloned for each instance of the class, and is NOT shared between instances of the class. If the variable is defined outside of the class, it is global, and has NOTHING to do with the class.
int g_pin; // global, not related to the class
class something
{
public:
static int s_pin; // Owned by the class, not usable by any instance of the class
int m_pin; // Cloned for each instance of the class
};
What you describe is not possible or is it?
The class can have a static method, doSomeBarking() that is called when the doorbell rings. The class can have a static method, letMeBark(), that any instance can call, to indicate that it wants to bark. The class can have a static pointer to an instance of the class, set by the letMeBark() function, pointing to the one dog that wants to bark. The class can have a static array of pointers, pointing to each of the dogs that wants to bark.
So, yes, it is possible to have a static method of the class deal with the interrupt, and have a specific instance of the class, or many instance of the class, do something when the interrupt happens.
An interupt is attached to a pin. So all dogs would bark, no?
No. The callback is to a class method, not an instance method. It is up to the class to determine what to do when the interrupt happens. It could make the last dog bark, or, as suggested above, any specific dog, or all dogs. But, the dogs do not bark just because the doorbell rang.