I have program which implements database of peoples and his companies. I have created dynamic array of pointer to class members instead of dynamic array of class members, cause copying is quicker with it.
I have version which works but valgrind shows mismatch delete in destructor (delete db)
CCompany** db;
~CCompanyIndex ( void )
{
for(unsigned i=0;i<len;i++)
{
/*cout<<"dealloc:"<<db[i]<<endl;*/
delete db[i];
}
delete db;
}
CCompanyIndex ( void )
{
max=1000;
len=0;
db=new CCompany*[max];
}
I use also to add
CCompany* newIt=new CCompany(oName,oAddr,cName,cAddr);
So I have tried following code which I consider correct previously
~CCompanyIndex ( void )
{
delete [] db;
}
But then all memory allocated by adding method is not deallocated.