什么是析构函数?一般用来完成什么任务?

bytt 2001-12-20 11:09:50
...全文
144 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
countrynew 2001-12-20
  • 打赏
  • 举报
回复
就是 上面说的了
Last_Dodo 2001-12-20
  • 打赏
  • 举报
回复
Destructor has only one task that is to release all the resources owned by this class. The resource could be memory (including shared memory), opened files, network connections, etc. The key is that if the class is the owner of the resources the destructor has to release them otherwise it could cause problem in your process (if the OS handle resource release when a process dies) or the whole machine (if the OS does not release resource when a process dies).
linhui 2001-12-20
  • 打赏
  • 举报
回复
析构函数: 主要是释放对象所占的内存

你可以定义它 如你没有定义系统会自动调用隐视的析构函数来释放

其实你没有必要来着问这么简单的问题 ( 基础C++ ) 上都有 OK!!!!
jimw 2001-12-20
  • 打赏
  • 举报
回复
用来释放你在类中定义的一些对象,如内存,名柄,关闭DB或Socket连接 etc.
Liusp 2001-12-20
  • 打赏
  • 举报
回复
是用来释放对象的
maoxianwang 2001-12-20
  • 打赏
  • 举报
回复
偶上边四层的说的对
happyforever 2001-12-20
  • 打赏
  • 举报
回复
说简单点,就是做善后工作,不要出现什么异常

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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