如何理解这句话

yuren5340468 2004-04-23 07:03:54
TButton *MyButton = new TButton(this);//这里的this指针指的是什么
MyButton->Parent = this;//parent又是什么,为什么要付this
...全文
54 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
qiuafa 2004-04-23
  • 打赏
  • 举报
回复

1 为 Owner
用Owner的Components[i]可以找到MyButton
Owner销毁时,自动销毁MyButton

2 为 Parent
用 Parent的Controls[i]可以找到MyButton
Parent销毁时,不会销毁MyButton

WbtServer 2004-04-23
  • 打赏
  • 举报
回复
Parent就是MyButton的父母,MyButton->Parent = this这句华的意思是MyButton是属于This的。
GeoPhoenix 2004-04-23
  • 打赏
  • 举报
回复
this是申请这个button这个空间的对象的指针,例如在一个form中动态生成一个button对象,this就是指向form的地址指针

604

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder VCL组件使用和开发
社区管理员
  • VCL组件使用和开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧