条款13:以对象管理资源
使用RAII,获得资源后立刻放进管理对象,管理对象运用析构函数确保资源被释放。
为防止资源泄露,请使用RAII对象,它们在构造函数中获得资源并在析构函数中释放资源。
两个常被使用的RAII类是tr1::shared_ptr和tr1::auto_ptr。前者通常是较佳选择,因为其拷贝行为比较直观。若选择auto_ptr,复制动作会使被复制物指向null.
 条款14...
                            
                            
                                分类:
编程语言   时间:
2014-08-22 16:22:49   
                                阅读次数:
250
                             
                         
                    
                        
                            
                            
                                这里直接把在网上的找到的答案记录下来,原文地址:http://www.oschina.net/question/109676_15561:如果出现启动 Eclipse 弹出“Failed to load the JNI shared library jvm.dll”错误,原因1:给定目录下jvm.d...
                            
                            
                                分类:
系统相关   时间:
2014-08-21 22:39:54   
                                阅读次数:
707
                             
                         
                    
                        
                            
                            
                                I know cheap ghds this probably sounds really vain but I live in upstate NY and the elements sucks! I ghds am just in need of a few foils to embellish...
                            
                            
                                分类:
其他好文   时间:
2014-08-21 12:58:04   
                                阅读次数:
202
                             
                         
                    
                        
                            
                            
                                TARGET_LIB:=libsqlite3.so
LIBS  	:= -lpthread -ldl
CFLAGS  := -g -Wall -shared -fPIC -I. $(LIBS)
CC		:= mipsel-openwrt-linux-gcc #交叉编译下的编译路径
STRIP	:= mipsel-openwrt-linux-strip
OBJ		:= sqlite3.o
all...
                            
                            
                                分类:
数据库   时间:
2014-08-21 11:34:24   
                                阅读次数:
631
                             
                         
                    
                        
                            
                            
                                13.27 定义使用引用计数版本的HasPtr#include#include#includeusing namespace std;class HasPtr{public: HasPtr(const string &s=string()):ps(new string(s)),i(0),use...
                            
                            
                                分类:
其他好文   时间:
2014-08-20 23:59:13   
                                阅读次数:
474
                             
                         
                    
                        
                            
                            
                                Given a collection of integers that might contain duplicates, S, return all possible subsets.Note:Elements in a subset must be in non-descending order...
                            
                            
                                分类:
其他好文   时间:
2014-08-20 19:37:12   
                                阅读次数:
175
                             
                         
                    
                        
                            
                            
                                1、在资源管理类中提供对原始资源的访问 前几个条款很棒,它们是对抗资源泄露的壁垒,但很多APIs直接指向 资源,这个时候,我们需要直接访问原始资源。 这里,有两种方法解决上述问题,我们可将RAII对象转换为原始资源。通过 显式转换与隐式转换。 通常,tr1:: shared_ptr 和 auto_p...
                            
                            
                                分类:
编程语言   时间:
2014-08-20 16:14:02   
                                阅读次数:
177
                             
                         
                    
                        
                            
                            
                                对于函数: int priority(); void processWidget(std::tr1:: shared_ptr pw,int priority); 调用以上函数 processWidget(new Widget,priority()); 以上调用错误,因为shared_ptr构造函数需...
                            
                            
                                分类:
编程语言   时间:
2014-08-20 16:11:22   
                                阅读次数:
194
                             
                         
                    
                        
                            
                            
                                总体概念block和inline这两个概念是简略的说法,完整确切的说应该是 block-level elements (块级元素) 和 inline elements (内联元素)。block元素通常被现实为独立的一块,会单独换一行;inline元素则前后不会产生换行,一系列inline元素都在一行...
                            
                            
                                分类:
其他好文   时间:
2014-08-20 16:10:12   
                                阅读次数:
245
                             
                         
                    
                        
                            
                            
                                Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array whic...
                            
                            
                                分类:
其他好文   时间:
2014-08-20 14:06:32   
                                阅读次数:
182