Deletion of this pointer
<p>This is regarding deletion of this pointer for an object allocated on heap.Program is as follows,</p>

<pre><code>class Sample{
      private:
              int m_value1;
              int m_value2;

      public:
             Sample();
             void setValues(int m_value1, int m_value2);
             void display();
      };

Sample::Sample(){
                 this-&gt;m_value1 = 0;
                 this-&gt;m_value2 = 0;
                 }

void Sample::setValues(int m_value1, int m_value2){
     this-&gt;m_value1= m_value1;
     this-&gt;m_value2 = m_value2;
     display();
     if(this != NULL)
     {
             cout &lt;&lt;"Deleting this pointer!"&lt;&lt;endl;
             delete this;
             cout &lt;&lt;"this-&gt;m_value1 is "&lt;&lt;this-&gt;m_value1&lt;&lt;endl;
             cout &lt;&lt;"this-&gt;m_value2 is "&lt;&lt;this-&gt;m_value2&lt;&lt;endl;

     }
     }

void Sample::display(){
     cout &lt;&lt;"Values are "&lt;&lt;this-&gt;m_value1&lt;&lt;" and "&lt;&lt;this-&gt;m_value2&lt;&lt;endl;

     }

int main(){
    Sample *obj1 = new Sample();;
    obj1-&gt;setValues(4,6);
    obj1-&gt;display();
    getch();
}
</code></pre>

<p>OUTPUT:</p>

<pre><code>Values are 4 and 6
Deleting this pointer!
this-&gt;m_value1 is 65535
this-&gt;m_value2 is 6
Values are 65535 and 6
</code></pre>

<p>Why does the value for m_value1 disappear whereas it stays for the other variable m_value2?</p>
