6

C++编码陷阱总结_小小石的技术博客_51CTO博客

 2 years ago
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.
neoserver,ios ssh client

C++编码陷阱总结

原创

wx62cfcb7ca1c5d 2022-07-14 16:08:12 博主文章分类:C++编码 ©著作权

文章标签 初始化 数组 内存泄露 文章分类 C/C++ 编程语言 阅读数180

对象数组的创建最好一次性创建出来,单个new,地址不连续不相关,容易形成陷阱。

对函数的返回值在函数开始处需要进行初始化,放置在过程中出错返回,导致程序崩溃。

2     localtime

localtime返回tm指针,对象是由内核创建,只有一个对象,mktime会更新localtime对象的指针

localtime的实现是使用了一个内部静态缓存来保存结果。

3     数组的最大长度

当类的成员数组的长度定为819200*3时,出现内存泄露

  • 收藏
  • 评论
  • 分享
  • 举报

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK