locked
When will a destructor on a ref class get called

    Question

  • Hello, I'm trying to release a ref class like this

    header

    class

    {

    private:

    MyClass^ m_myClass;

    }

    source

    m_myClass = ref new MyClass();

    m_myClass = nullptr;

    However the destructor of MyClass() does not get called.  Should this happen if the pointer is nulled, if not, would it be correct to call delete on m_myClass first?  This works, but doesn't seem great since something else could be holding a ref to MyClass().  Also is it possible to see the current ref count for m_myClass, in case something else is holding a reference?

    Saturday, December 20, 2014 3:26 PM

Answers

All replies