`
阿尔萨斯
  • 浏览: 4188051 次
社区版块
存档分类
最新评论

C++ Gotchas 第6章 内存及资源管理

 
阅读更多
<iframe align="center" marginwidth="0" marginheight="0" src="http://www.zealware.com/csdnblog.html" frameborder="0" width="728" scrolling="no" height="90"></iframe>

6 . Memory and Resource Management<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

6 内存及资源管理

C++在内存管理方面提供了极大的弹性,但几乎没有多少C++程序员完全通透其理。C++在这一方面,经由重载(overloading)、名称隐藏(name hiding)、构造(constructors)与析构(destructors)、异常(exceptions)、静态函数(static functions)与虚函数(virtual functions)、运算符函数(operator functions)与非运算符函数(non-operator functions),一起为内存管理提供了非凡的弹性和可定制性。而不幸的是——或许也不可避免的是——事情变得有些复杂了。

在本章中,我们来看一看C++的各种语言特征:如何一起用于内存管理;如何时而以令人吃惊的方式相互影响;如何消减其间的相互影响。

内存只是程序所管理的许多资源之一,因此我们还要看一看,如何将其它资源绑定到内存,使我们可以利用C++纷繁的内存管理设施来管理其它资源。

6 内存及资源管理

Gotcha #60: Failure to Distinguish Scalar and Array Allocation
Gotcha条款60:没能区分单体内存分配与数组内存分配

Gotcha #61: Checking for Allocation Failure
Gotcha条款61:检查内存分配失败的情形

Gotcha #62: Replacing Global New and Delete
Gotcha条款62:替换Global New和Global Delete

Gotcha #63: Confusing Scope and Activation of Member new and delete
Gotcha条款63:Member New和Member Delete之生存期与活动空间的迷惑

Gotcha #64: Throwing String Literals
Gotcha条款64:抛出String Literals

Gotcha #65: Improper Exception Mechanics
Gotcha条款65:不够适宜的异常机制

Gotcha #66: Abusing Local Addresses
Gotcha条款66:滥用局部地址空间

Gotcha #67: Failure to Employ Resource Acquisition Is Initialization
Gotcha条款67:没能秉持“Resource Acquisition Is Initialization(资源获取即初始化)”原则

Gotcha #68: Improper Use of auto_ptr
Gotcha条款68:auto_ptr的不当用法




分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics