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

王朝c/c++·作者佚名  2006-01-08
宽屏版  字体: |||超大  

6 . Memory and Resource Management

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的不当用法

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有