为什么没有调用析构函数? [英] Why is the destructor not called?

查看:210
本文介绍了为什么没有调用析构函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我这样做两次时:

Window :: Current-> Content = ref new MainPage();

Window::Current->Content = ref new MainPage();

Window :: Current-> Content = ref new MainPage();

Window::Current->Content = ref new MainPage();

应该调用第一个调用的析构函数。但这不会发生

the destructor of the first call should be called. But this does not happen

当我宣布这个课程时:

公共参考课程人员¥b $ b  {

  public:

   Person();

   ~Person();

 };

public ref class Person
 {
 public:
  Person();
  ~Person();
 };

并执行此操作:

Person ^ p = ref new Person();

Person^ p = ref new Person();

p = ref new Person();

p = ref new Person();

第一次调用的析构函数被调用。

the destructor for the first call gets called.

推荐答案

它似乎与继承有关:

It seems to have something to do with the inheriance:

部分ref类MainPage:public Windows :: UI :: Xaml :: Controls :: UserControl ,...

partial ref class MainPage: public Windows::UI::Xaml::Controls::UserControl, ...

但问题仍然是:为什么 是否未调用destuctor?

but still the question: why is the destuctor not called?


这篇关于为什么没有调用析构函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆