0

I want to notify to another class that a variable was changed, so that I using a callback called notify. I'm a beginner in c++ language and was seeking for the best way to do this and I decided to do it with std::function. But it shows an error, because the callback class is in another file and I can't access to the notify function.

77 IntelliSense: class "std::function" has no member "notifyMsg" (...) ClientTs.cpp

ClientTS.cpp

cbClientTsFrm callbckFrmGUI;

void registercb(cbClientTsFrm fn){
    callbckFrmGUI = fn;
}
....
// in another function:
callbckFrmGUI.notifyMsg(msgC);

ClientTS.h

class ClientTsFrm; 
typedef std::function<void(const ClientTsFrm&)> cbClientTsFrm;

ClientTSFrm.h

class ClientTsFrm : public wxFrame
{
    public:

        explicit  ClientTsFrm(LoginWarnings *warn, wxWindow *parent, wxWindowID id = 1, const wxString &title = wxT("TeamTranslate"),
                    const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, 
                    long style = wxCAPTION | wxSYSTEM_MENU | wxCLOSE_BOX | wxRESIZE_BORDER);
(....)
        void notifyMsg(MessagePTR msg);
};

I've tried to use Template, but it doesn't work. Please, aside my trouble, any suggestion is welcomed. Thank you.

Daniel 976034
  • 189
  • 1
  • 1
  • 18

0 Answers0