wxWidgets学习-3--new与delete(此片为转贴)

 所有从 wxWindow 继承的类都会有个 wxWindow* parent 参数,这样它的父窗口可以通过 GetChildren() 方法获得所有的子窗口,
 include/wx/window.h 行 537
 wxWindowList& GetChildren() { return m_children; }
所以只要是继承的 wxWindow 的类都会在它的父窗口被删除时被父窗口释放,可以查看
 src/common/wincmn.cpp 行 276
 wxWindowBase::~wxWindowBase()
也就是只要保证最上层的父窗口被删除就不用去 delete。
像 wxImageList 这种类
wxImageList()
Default constructor.
wxImageList(int width, int height, const bool mask = true, int initialCount = 1)
Constructor specifying the image size, whether image masks should be created, and the initial size of the list.
在构造函数中没有 wxWindow* parent 参数就需要自己删除。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值