Wahalez
Wahalez

Reputation: 489

No matching constructor for class initialization

I have this class :

class instaStalkPanel : public wxPanel {
private:
    
public:
    instaStalkPanel(wxWindow *parent, wxWindowID id, wxPoint &pos, wxSize &size, long style, const wxString &name);
    
    wxDECLARE_EVENT_TABLE();
};

Now I'm trying to initialize a pointer variable of this class like this, in another class called instaStalkFrame :

mainPanel = new instaStalkPanel(this, ID_PANEL_MAIN, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, "panel");

The error it gives me :

No matching constructor for initialization of 'instaStalkPanel'

Any ideas why this happens ?

The constructor function :

instaStalkPanel::instaStalkPanel(wxWindow *parent, wxWindowID id, wxPoint &pos, wxSize &size, long style, const wxString &name) : wxPanel(parent, id, pos, size, style, name){
    
}

Upvotes: 0

Views: 182

Answers (1)

molbdnilo
molbdnilo

Reputation: 66371

You're trying to bind non-const references (pos and size) to const objects.
Make the parameters const wxPoint& and const wxSize&.

Upvotes: 1

Related Questions