ITPub博客

首页 > > > 成员变量析构:对象会主动调用析构函数

成员变量析构:对象会主动调用析构函数

作者:友哥 时间:2018-09-05 15:30:00 0 删除 编辑
#include <iostream>
#include <list>

class destructor_test{
public:
  ~destructor_test(){
    std::cout << "~destructor_test" << std::endl;
  }
};

class test{
private:
  destructor_test destructor_test_instance;
};


int main ()
{
  test * test_instance = new test();
  delete test_instance;

  return 0;
}

 

原文作者:;如有侵权,请联系管理员删除。

请登录后发表评论 登录
全部评论

注册时间:2020-05-20

  • 博文量
    276
  • 访问量
    1000