How can I create callbacks in a C++ class that are referenced to another class?

Viewed 35

My code look like this and I'm struggle to understand some concepts, maybe you can help me.

this is the header file

#include <WiFi.h>
class DeviceManager {
    private:
    WiFiEventHandler wifiConnectedHandler = WiFi.onStationModeGotIP(&onWiFiConnected);
    void onWiFiConnected(const WiFiEventStationModeGotIP& evt);
};

I get an error

no suitable constructor exists to convert from "void(DeviceManager::*)(const WiFiEventStationModeGotIP& evt)" to <std::function<void (const WiFiEventStationModeGotIP&)>

0 Answers
Related