NULL In a Class Destructor

Posted by Hyper-DarkStar on Stack Overflow See other posts from Stack Overflow or by Hyper-DarkStar
Published on 2011-02-13T15:15:50Z Indexed on 2011/02/13 15:25 UTC
Read the original article Hit count: 201

Filed under:
|
|
|
|

Simple question; Is it pointless to set a pointer( which allocates heap memory ) to NULL in the destructor?

class SampleClass
{
    public:
        SampleClass( int Init = 0 )
        {
            Value = new int( Init );
        }

        ~SampleClass( void )
        {
            delete Value;
            Value = NULL; // Is this pointless?
        }

        int *Value;
};

While on the subject of classes, when should I use the explicit keyword?

Thanks.

© Stack Overflow or respective owner

Related posts about c++

Related posts about class