开发者

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜