As mentioned by Salem you should be using new and not malloc here. The later does not construct the std::string data member location, it simply allocates sizeof(std::string) space for that member...