开发者

Using wxAny as a container class for wxControls

开发者 https://www.devze.com 2023-02-03 14:35 出处:网络
Can the wxAny class be used to store a wxCheckBox class or o开发者_C百科ther wxControl based classes?

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&);
0

精彩评论

暂无评论...
验证码 换一张
取 消