typedef void (*callbackFunc) (int arg1); //is int right ?
for typing a function signature you can just use:
typedef void (*callbackFunc) (int);
but prefer to use your C++, because you do not need to create a new type, it already exists:
using callbackFunc = void (*)(int);
uninitialized class member pointers will be nullptr by default, but I like that you explicitly initialize it.
you don't need all this:
void TestCallback::update(callbackFunc func = nullptr)
{
if (func == nullptr)
{
_callbackRequired = false;
}
else
{
cb1 = func;
_callbackRequired = true;
}
pointers can be truth tested:
if (func) {
cb1 = func;
}
likewise when you call it... not like this:
if (_callbackRequired)
{
cb1(_currentCount); //execute the callback function
}
but this:
if (cb1)
{
cb1(_currentCount); //execute the callback function
}
so you save a variable, _callbackRequired isn't necessary.