Using wxAny as a container class for wxControls
Can the wxAny class be used to store a wxCheckBox class or o开发者_C百科ther wxControl based classes?
wxPanel *panel = new wxPanel(this, wxID_ANY);
wxCheckBox test(panel, idMenuAbout + 1, wxT("Show title"), wxPoint(20, 20));
wxAny checkBox = test;
The above code generates the error 'wxCheckBoxBase& wxCheckBoxBase::operator=(const wxCheckBoxBase&)’ is private
Thanks.
The problem is not with wxAny
but with the fact that wxCheckBoxBase
is made non-copyable:
wx/checkbox.h
class WXDLLEXPORT wxCheckBoxBase : public wxControl
protected:
DECLARE_NO_COPY_CLASS(wxCheckBoxBase)
}
wx/defs.h
/* --------------------------------------------------------------------------- */
/* macro to define a class without copy ctor nor assignment operator */
/* --------------------------------------------------------------------------- */
#define DECLARE_NO_COPY_CLASS(classname) \
private: \
classname(const classname&); \
classname& operator=(const classname&);
精彩评论