例子
typedef struct
{ std:string features;} Row;
Row row;
row.feautres = "hello";
可能出错,因为struct分配的时候,仅仅是分配内存空间,并没有对里面的对象进行必要的初始化,这样就有可能到只row.features.assign(xxx)报错segment fault(概率性的)
参考:
- http://stackoverflow.com/questions/20452581/segmentation-fault-assigning-stdstring-in-a-struct
- http://stackoverflow.com/questions/3411815/how-to-use-a-c-string-in-a-structure-when-malloc-ing-the-same-structure