6
C++编码陷阱总结_小小石的技术博客_51CTO博客
source link: https://blog.51cto.com/u_15718440/5472132
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
C++编码陷阱总结
原创对象数组的创建最好一次性创建出来,单个new,地址不连续不相关,容易形成陷阱。
对函数的返回值在函数开始处需要进行初始化,放置在过程中出错返回,导致程序崩溃。
2 localtime
localtime返回tm指针,对象是由内核创建,只有一个对象,mktime会更新localtime对象的指针
localtime的实现是使用了一个内部静态缓存来保存结果。
3 数组的最大长度
当类的成员数组的长度定为819200*3时,出现内存泄露
- 赞
- 收藏
- 评论
- 分享
- 举报
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK