I am new to C ++. I get a HEAP CORRUPTION ERROR. Any help would be greatly appreciated. Below is my code
class CEntity
{
CEntity(string section1,string section2);
CEntity();
virtual ~CEntity();
virtual CEntity* create()const = 0;
};
I get CLine from CEntity as below
class CLine:public CEntity
{
CLine(string section1,string section2);
CLine();
~CLine();
CLine* Create() const;
}
CLine::CLine(string section1,string section2) : CEntity(section1,section2){};
CLine::CLine();
CLine* CLine::create() const {return new CLine();}
I have another CReader class that uses a CLine object and populates it as a multimap, as shown below
class CReader
{
public:
CReader();
~CReader();
multimap<int,CEntity*>m_data_vs_entity;
};
CReader::CReader()
{
m_data_vs_entity.clear();
};
CReader::~CReader()
{
multimap<int,CEntity*>::iterator iter;
for(iter = m_data_vs_entity.begin();iter!=m_data_vs_entity.end();iter++)
{
CEntity* current_entity = iter->second;
if(current_entity)
delete current_entity;
}
m_data_vs_entity.clear();
}
, CLine. CReader. CEntity , , CReader . , , HEAP CORRUPTION ERROR . - , , , , , .
,
,
Atul
Y'day:
, , , - , .
, .
CEntity::CEntity(string section1,string section2)
{
size_t length;
char buffer[9];
length = section1.copy(buffer,8,0);
buffer[length]='\0';
m_entity_type = atoi(buffer);
length = section1.copy(buffer,8,8);
buffer[length]='\0';
m_param_data_pointer = atoi(buffer);
}
8 , '\ 0', , , , .
: (XXX) XXX CRT , .. , - , . , - , .
,