toolbar.cpp||In constructor 'ToolBar::ToolBar()':|
toolbar.cpp|5|error: no matching function for call to 'wxAuiToolBar::wxAuiToolBar()'|
So my question is why does this error occur? Can't my class have its own constructor? This is the definition of wxAuiToolBar:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
//auibar.h
class WXDLLIMPEXP_AUI wxAuiToolBar : public wxControl
{
public:
wxAuiToolBar(wxWindow* parent,
wxWindowID id = -1,
const wxPoint& position = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxAUI_TB_DEFAULT_STYLE);
~wxAuiToolBar();
//...
};
If I make ToolBar have the same constructor parameters as wxAuiToolBar's constructor parameters, I get the same error. Does anybody know what I can do to fix this? Thanks for any help.
wxAuiToolBar has no default constructor as you can see. It has to be created using:
1 2 3 4 5
wxAuiToolBar(wxWindow* parent,
wxWindowID id = -1,
const wxPoint& position = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxAUI_TB_DEFAULT_STYLE);
As you can see, you need to create it with at least wxWindow* parent parameter (as the other parameters have default values).
This means that in your:
1 2 3 4
ToolBar::ToolBar()
{
}
You will have to explicitly call the wxAuiToolBar constructor:
1 2 3 4
ToolBar::ToolBar() : wxAuiToolBar(parent)
{
}
But how are you going to get a wxWindow* to pass on to the wxAuiToolBar base class??
You will have to change your Toolbar constructor to one which takes at least a wxWindow*
parameter.
Like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
//toolbar.h
#ifndef TOOLBAR_H
#define TOOLBAR_H
#include "main.h"
class ToolBar : public wxAuiToolBar
{
public:
ToolBar(wxWindow* parent);
~ToolBar();
};