How to pass a function from a class to a structure

struct Command
{
    char const *text;
    void (*f)(void);
    bool active;
};

/* enumeration of objects - commands */
Command commands[]
{
    {"clearcom", clearCommandTerminal, false},
    {"dectop", desctop, true},
    {"deepsleep", powerSaveDeepSleep, true},
    {"systray", systemTray, true},
    {"app_desctop", _desc.window("f"), true}
};

I can't convey this _desc.window("f")

Tell me the solution. This code that I have given is located in the library file (ex.cpp), this library will be used by the user.

How to implement a mechanism so that the user can add his own function to the array?

What platform? If it's not an AVR, you can put a std::function in the struct. That can then accept a std::bind or a lambda.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.