title: C++, Error, Native' has exited with code -1073741819 (0xc0000005)
body: <p>I wrote a programe in C++ but in debugging I encountered a problem, I'll be glad if you can help me in this Code,The Source of the code and the error has been declaired in the following :</p>
  
  <p>The error is:</p>
  
  <pre><code>Unhandled exception at 0x011019d6 in 33.exe: 0xC0000005: Access violation reading location 0xcdcdcdcd.
  </code></pre>
  
  <p>The Code is: </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std; 
  const int maxCard =100;
  //enum Boll {false, true};
  
  class Contact 
  {
  
  public:
      Contact (const char *name, const char *address, const char *tell);
      //~ Contact(void);
      const char* Name (void)  const {return name;}
      const char* Address (void) const {return address;}
      const char* Tell (void) const {return tell;}
      friend ostream&amp; operator&lt;&lt; (ostream&amp;, Contact&amp;);
  private:
      char *name;
      char *address;
      char *tell;
  };
  class ContactDir 
  {
  public:
      ContactDir(const int maxSize);
      //~ContactDir(void);
      void Insert(const Contact &amp;);
      void Delete(const char *name);
      Contact* Find(const char *name);
      friend ostream&amp; operator &lt;&lt;(ostream&amp;, ContactDir&amp;);
  private: 
      int Lookup (const char *name);
      Contact **contacts;
      int dirSize;
      int maxSize;
  };
  Contact::Contact(const char *name, const char *address, const char *tell)
  {
      Contact::name= new char [strlen(name)+1];
      Contact::address= new char [strlen(address)+1];
      Contact::tell= new char [strlen(tell)+1];
      strcpy(Contact::name, name);
      strcpy(Contact::address, address);
      strcpy(Contact::tell,tell);
  }
  /*Contact::~Contact (void)
  {
      delete name;
      delete address;
      delete tell;
  }*/
  ostream &amp;operator&lt;&lt;(ostream &amp;os, Contact &amp;c)
  {
      os&lt;&lt;"("&lt;&lt;c.name&lt;&lt;","&lt;&lt;c.address&lt;&lt;","&lt;&lt;c.tell&lt;&lt; ")";
      return os;
  }
  ContactDir::ContactDir (const int max)
  {
      typedef Contact *ContactPtr;
      dirSize=0;
      maxSize=max;
      contacts= new ContactPtr[maxSize];
  };
  /*ContactDir::~ContactDir (void)
  {
      for(register int i=0; i&lt;dirSize; ++i)
          delete contacts[i];
      delete []contacts;
  }*/
  void ContactDir::Insert (const Contact&amp; c)
  {
      if (dirSize&lt;maxSize)
      { 
          int idx= Lookup(c.Name());
          if(idx&gt;0 &amp;&amp;strcmp(c.Name(), contacts[idx]-&gt;Name())==0)
          { 
              delete contacts [idx];
          }
          else 
          {
              for (register int i=dirSize; i&gt;idx; --i)
                  contacts[i]=contacts[i-1];
              ++dirSize;
          }
          contacts[idx]=new Contact (c.Name(),c.Address(),c.Tell());
      }
  }
  void ContactDir::Delete (const char *name)
  {
      int idx=Lookup(name);
      if(idx&lt;dirSize)
      {
          delete contacts[idx];
          --dirSize;
          for (register int i=idx; i&lt;dirSize; i++)
              contacts[i]=contacts[i+1];
      }
  }
  Contact *ContactDir::Find (const char *name)
  {
      int idx= Lookup (name);
      return (idx&lt; dirSize &amp;&amp; strcmp (contacts[idx]-&gt;Name(), name)==0)? contacts[idx]:0;
  }
  int ContactDir:: Lookup (const char *name)
  {
      for (register int i=0; i&lt;dirSize; ++i)
          if (strcmp (contacts[i]-&gt;Name(), name)==0)
              return i;
      return dirSize;
  }
  
  ostream &amp;operator &lt;&lt; (ostream &amp;os, ContactDir &amp;c)
  {
      for (register int i=0; i&lt;c.dirSize; ++i)
          os&lt;&lt; *(c.contacts[i]) &lt;&lt; '\n';
      return os;
  }
  
  int main (void)
  {
      ContactDir dir (10);
      dir.Insert(Contact ("JACK","NORWAY", "999999"));
      dir.Insert(Contact ("JIMMY","FRANCE", "313131"));
      cout&lt;&lt;dir;
  
  }
  </code></pre>