title: Unhandled exception at 0x00418c38 in test.exe: 0xC0000005: Access violation reading location 0xfffffffc
body: <p>I've implemented a Smart Pointer class, when i tried to compile, it stops on a specific line and i get this messege: <strong>Unhandled exception at 0x00418c38 in test.exe: 0xC0000005: Access violation reading location 0xfffffffc.</strong></p>
  
  <p>my code is: </p>
  
  <pre><code>  template &lt;class T&gt;
  class SmartPointer
  {
      private:
          T* ptr;
          int* mone;
      public: 
          SmartPointer() : ptr(0), mone(0) //default constructor
          {
              int* mone = new int (1); 
          }
  
           SmartPointer(T* ptr2) : ptr(ptr2), mone(0)
           {
               int* mone = new int (1);        
           }
  
          SmartPointer&lt;T&gt;&amp; operator= (const SmartPointer&amp; second) //assignment operator
          {
              if (this!= &amp;second)
              {
                  if (*mone==1)
                  {
                      delete ptr; 
                      delete mone;
                  }
  
                  ptr = second.ptr;
                  mone = second.mone;
                  *mone++;
              }
              return *this;
          }
  
          ~SmartPointer() // Destructor
          {
              *mone--;
              if (*mone==0)
              {
                  delete ptr;
                  delete mone;
              }
          }
  };
  </code></pre>
  
  <p>i also have a * and &amp; overloading functions and a copy constructor.</p>
  
  <p>it stops here: </p>
  
  <pre><code>if (*mone==0)
  </code></pre>
  
  <p>could you please help me?? thaks</p>