title: Getting pointer attribute value
body: <p>im working on this exercise about operators overloading and references. The problem is that when i ask for the value in the "itsRadius" pointer attribute of the SimpleCircle class, im getting strange values... Also, if i have this destructor:</p>
  
  <pre><code>SimpleCircle::~SimpleCircle()
  {
      delete itsRadius;
      itsRadius = 0;
  }
  </code></pre>
  
  <p>i get the "_block_type_is_valid(phead-> nblockuse)" error. The idea is having this detructor to delete the memory allocated for the attribute in the class... I know that this error is triggered when i delete two times something that was already deleted, but i dont know where this happened... is that so?</p>
  
  <p>here is the hole code of the exercise:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  class SimpleCircle
  {
      public:
      SimpleCircle();
      SimpleCircle( int );
      SimpleCircle( SimpleCircle&amp; );
      ~SimpleCircle();
  
      void setRadius ( int );
      int getRadius() const { return *itsRadius; };
  
      const SimpleCircle&amp; operator++();
      const SimpleCircle operator++( int );
      SimpleCircle&amp; operator=( const SimpleCircle&amp; );
  
      private:
      int *itsRadius;
  };
  
  SimpleCircle::SimpleCircle()
  {
      itsRadius = new int(5);
  }
  
  SimpleCircle::SimpleCircle(int radius)
  {
      itsRadius = new int(radius);
  }
  
  SimpleCircle::SimpleCircle( SimpleCircle &amp; rhs )
  {
      int val = rhs.getRadius();
      itsRadius = new int (val);
  }
  
  SimpleCircle::~SimpleCircle()
  {
      delete itsRadius;
      itsRadius = 0;
  }
  
  const SimpleCircle&amp; SimpleCircle::operator++()
  {
      ++itsRadius;
      return *this;
  }
  
  const SimpleCircle SimpleCircle::operator++(int)
  {
      SimpleCircle temp(*this);
  
      ++(itsRadius);
      return temp;
  }
  
  SimpleCircle&amp; SimpleCircle::operator=( const SimpleCircle&amp; rhs)
  {
      if (this == &amp;rhs) { return *this; }
      *itsRadius = rhs.getRadius();
      return *this;
  }
  
  void main()
  {
      SimpleCircle a, b(9);
      a++;
      ++b;
      cout &lt;&lt; a.getRadius();
      cout &lt;&lt; b.getRadius();
      a = b;
      cout &lt;&lt; a.getRadius();
      cout &lt;&lt; b.getRadius();
      system("pause");
  }
  </code></pre>