More Effective C++

Scott Meyers

出版时间

1996-01-08

ISBN

9780201633719

评分

★★★★★
书籍介绍
More than 150,000 copies in print! Praise for Scott Meyers' first book, Effective C++: "I heartily recommend Effective C++ to anyone who aspires to mastery of C++ at the intermediate level or above." - The C/C++ User's Journal From the author of the indispensable Effective C++, here are 35 new ways to improve your programs and designs. Drawing on years of experience, Meyers explains how to write software that is more effective: more efficient, more robust, more consistent, more portable, and more reusable. In short, how to write C++ software that's just plain better. More Effective C++ includes: * Proven methods for improving program efficiency, including incisive examinations of the time/space costs of C++ language features * Comprehensive descriptions of advanced techniques used by C++ experts, including placement new, virtual constructors, smart pointers, reference counting, proxy classes, and double-dispatching * Examples of the profound impact of exception handling on the structure and behavior of C++ classes and functions * Practical treatments of new language features, including bool, mutable, explicit, namespaces, member templates, the Standard Template Library, and more. If your compilers don't yet support these features, Meyers shows you how to get the job done without them. More Effective C++ is filled with pragmatic, down-to-earth advice you'll use every day. Like Effective C++ before it, More Effective C++ is essential reading for anyone working with C++.
AI导读
核心看点
  • 35条进阶技巧,提升C++程序效率与健壮性
  • 深入剖析指针与引用的本质区别及最佳实践
  • 详解虚函数、多重继承等高级特性的性能成本
适合谁读
  • 已掌握Effective C++基础的中级C++开发者
  • 希望深入理解C++底层机制与性能优化的程序员
  • 追求代码高质量、高复用性的资深软件工程师
读前提醒
  • 此书出版较早,部分语法已随C++11标准更新
  • 内容较深,建议结合现代C++标准对照阅读
  • 部分条目与Effective C++有重叠,可跳读
读者共识
  • 经典之作,技术深度优于前作,值得反复研读
  • 部分设计话题略显平淡,但高级技巧极具价值
  • 虽显过时,但核心思想至今仍是C++编程基石

本导读基于书籍简介、目录、原文摘录、短评和书评生成,不等同于全文精读。

精彩摘录
  • "…… 首先,要认识到在任何情况下都不能使用指向空值的引用。一个引用必须总是指向某些 对象。因此如果你使用一个变量并让它指向一个对象,但是该变量在某些时候也可能不指向任何对象,这时你应该把变量声明为指针,因为这样你可以赋空值给该变量。相反,如果变量肯定指向一个对象,例如你的设计不允许变量为空,这时你就可以把变量声明为引用。 …… 因为引用肯定会指向一个对象,在 C++里,引用应被初始化。 …… 不存在指向空值的引用这个事实意味着使用引用的代码效率比使用指针的要高。因为在使用引用之前不需要测试它的合法性。"
  • "…… 指针与引用的另一个重要的不同是指针可以被重新赋值以指向另一个不同的对象。但是引用则总是指向在初始化时被指定的对象,以后不能改变。 …… 总的来说,在以下情况下你应该使用指针,一是你考虑到存在不指向任何对象的可能 (在这种情况下,你能够设置指针为空),二是你需要能够在不同的时刻指向不同的对象(在这种情况下,你能改变指针的指向)。如果总是指向一个对象并且一旦指向一个对象后就不会改变指向,那么你应该使用引用。 还有一种情况,就是当你重载某个操作符时,你应该使用引用。最普通的例子是操作符[]。这个操作符典型的用法是返回一个目标对象,其能被赋值。 …… 当你知道你必须指向一个对象并且不想改变其指向"
  • "Note the tell-tale virtual destructor, a sure sign this class is designed for use as a base class (see Item E14). Note also how the destructor is a pure virtual function, a sure sign this class is designed to be used only as a base class. RCObject::~RCObject() {} // virtual destructors must always /"
下载
收藏