Skip to main content
Included mention of function visibility
Source Link
Peter Bloomfield
  • 11k
  • 9
  • 48
  • 87

dofun() is currently declared as a private member function, meaning you can't call it directly. It needs tocan only be called oninternally by an instance of the AllTimer class.

It looks like you probably want to declare it as a public static function instead, meaning you don't need an instance of the class. To do that, modifyremove the private specifier from the class declaration in, and put static before the function declaration. Your header file toshould look something like this:

class AllTimer
{
public:
    AllTimer();
    void setTimer(void);
    static void dofun(void);
};

You will then need to change the ISR to include the class name in the call:

ISR (TIMER1_OVF_vect)
{
    AllTimer::dofun();
}

dofun() is currently declared as a member function, meaning you can't call it directly. It needs to be called on an instance of the AllTimer class.

It looks like you probably want to declare it as a static function instead, meaning you don't need an instance of the class. To do that, modify the declaration in the header file to look like this:

static void dofun(void);

You will then need to change the ISR to include the class name in the call:

ISR (TIMER1_OVF_vect)
{
    AllTimer::dofun();
}

dofun() is currently declared as a private member function, meaning you can't call it directly. It can only be called internally by an instance of the AllTimer class.

It looks like you probably want to declare it as a public static function instead. To do that, remove the private specifier from the class declaration, and put static before the function declaration. Your header should look something like this:

class AllTimer
{
public:
    AllTimer();
    void setTimer(void);
    static void dofun(void);
};

You will then need to change the ISR to include the class name in the call:

ISR (TIMER1_OVF_vect)
{
    AllTimer::dofun();
}
Source Link
Peter Bloomfield
  • 11k
  • 9
  • 48
  • 87

dofun() is currently declared as a member function, meaning you can't call it directly. It needs to be called on an instance of the AllTimer class.

It looks like you probably want to declare it as a static function instead, meaning you don't need an instance of the class. To do that, modify the declaration in the header file to look like this:

static void dofun(void);

You will then need to change the ISR to include the class name in the call:

ISR (TIMER1_OVF_vect)
{
    AllTimer::dofun();
}