摘要:
智能指针机制跟Objective-C里面的retainCount引用计数有着相同的原理,当某个对象的引用计数为0是执行delete操作,类似于autorelease初学者在使用智能指针时,很多情况下可以把它当做标准C++中的T*来理解。比如:typedef boost::shared_ptr CMyLargeClassPtr;std::vector vec;vec.push_back( CMyLargeClassPtr(new CMyLargeClass("bigString")) );这里的CMyLargeClassPtr可以用CMyLargeClass *来理解,但是在 阅读全文
摘要:
pimpl (the pointer-to-implementation idiom)手法在 C++ 里已是“高手”们广泛运用的成熟方法之一,它的优点很多,诸如降低编译依赖、提高重编译速度之类的工具性优势自不待赘言,而其对“保持接口稳定性”的优点更值得称道。 It makes it possible to avoid other classes to know internal data structures and other information of the class. It also simplifies some#includepreprocessor instruct... 阅读全文