У меня есть простой класс
class symbol_entry
{
private:
static unsigned long uid;
public:
std::string name;
std::string filename;
unsigned int line_number;
unsigned int column_number;
symbol_entry* parent_symbol;
std::map<const char*,symbol_entry*> child_symbols;
unsigned long type_flags;
public:
symbol_entry();
symbol_entry(const char* name,
const char* filename,
int line_number,
int column_number,
symbol_entry* parent_symbol,
unsigned long type_flags);
~symbol_entry();
symbol_entry* get_child(const char* name);
bool put_child(symbol_entry* child);
};
. Вот реализация symbol_entry :: put_child;
bool symbol_entry::put_child(symbol_entry* child)
{
if(child_symbols[child->name.c_str()])
return false;
child_symbols.insert(std::make_pair(child->name.c_str(),child));
return true;
}
всякий раз, когда я выполняю такой тест;
symbol_entry* tsym=new symbol_entry("test","$",0,0,0,0);
symbol_entry* tcsym=new symbol_entry("test_child","$",0,0,0,0);
tsym->put_child(tcsym);
std::cout<<tsym->child_symbols.begin()->first<<" => "<<tsym->child_symbols.begin()->second<<std::endl;
child_symbols.begin () -> second хранит нулевой указатель.Я не могу решить это и перепробовал много вариантов, включая const и ссылки, чтобы помочь.