title: How to deallocate array of pointers to structures in C++?
body: <p>I've created class that implements array of pointers to structures... I know how to add records to this array, but I don't know, how to delete them properly and thus I've got memory leaks. The size of my array rises when needed and I know the size of an array and how many records do I have there. I'm used to code in languages, that have garbage collector, so this is quite confusing for me. I'd be glad if any of you could show me, how to deallocate properly that array.</p>
  
  <p>Pls note, that I can't use <code>vector</code>. I'm limited on includes to those:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  #include &lt;string&gt;
  #include &lt;cstring&gt;
  #include &lt;cstdlib&gt;
  #include &lt;cstdio&gt;
  </code></pre>
  
  <p>My code :
  </p>
  
  <pre><code>struct DbRecord
  {
      string oName;
      string oAddr;
      string cName;
      string cAddr;
  };
  
  class CCompanyIndex
  {
      public: CCompanyIndex(void);~CCompanyIndex(void);
      bool Add(const string &amp; oName,
      const string &amp; oAddr,
      const string &amp; cName,
      const string &amp; cAddr);
      bool Del(const string &amp; oName,
      const string &amp; oAddr);
      bool Search(const string &amp; oName,
      const string &amp; oAddr,
      string &amp; cName,
      string &amp; cAddr) const;
  
      int size;
      int position;
      DbRecord * * db;
  };
  
  CCompanyIndex::CCompanyIndex(void)
  {
      db = new DbRecord * [1000];
  
      size = 1000;
      position = 0;
  }
  
  CCompanyIndex::~CCompanyIndex(void)
  {
  }
  
  int main(int argc, char const * argv[])
  {
  
      CCompanyIndex c1;
      // do something..with c1, i.e. add there some records to array
      // ...
      // ...
      // delete it now
  }
  </code></pre>