My program crashes when I try to assign a string value to a member of a structure. My suspicion is that the member (of type string) within the structure was never properly alloc
The way you are allocating node
is incorrect: if you want to dynamically allocate non-POD types in C++, you need to use new
, since it will call the required constructors (followed by a call to delete
when appropriate).
But it might be simpler to allocate an automatic instance:
DataRow node;
If you do need a pointer, make sure to have a look at smart pointers, particularly std::unique_ptr and std::shared_ptr. See also boost::scoped_ptr.