struct 和 (对象)std:string不要混用
2014-04-17 10:27
260 查看
例子
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
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
相关文章推荐
- mac 访问mysql客户端
- 臭氧治疗冠心病成功案例 我就是其中一个
- 在xcode调试断点不能停在代码区的终极解决方案
- window.showModalDialog 弹出窗口获取父窗口对象 详解
- 在Windows下配置PHP开发环境
- ACEES 2007 导出表数据到 SQL SERVER (反过来过程相似)
- zoj 3710 Friends
- Altova MapForce AMS/ACI/ISF自定义模板
- Oracle PL/SQL 绑定变量
- delphi 开发的系统在win7下出现的 'Invalid data type for 'UserPreferencesMask'的解决
- JavaWeb学习篇之----自定义标签&&JSTL标签库详解
- 在Windows下配置PHP开发环境 分类: PHP 2014-04-17 10:26 111人阅读 评论(0) 收藏
- MVVM模式应用体会
- Ehcache的配置和使用
- JdbcTemplate与事务(容易理解)
- C++ Primer 第4版 阅读笔记 13.3:析构函数
- 指定URL的网络爬虫。。
- 《ubuntu下x86汇编》AT&T格式—as命令与s后缀文件
- 自己动手编写操作系统(一)-----Boot Sector
- linux2.6.30.4内核移植(2)——Nand Flash驱动移植