本书重点介绍了C++面向对象程序设计的底层机制,包括结构式语意、暂时性对象的生成、封装、继承和虚拟——虚拟函数和虚拟继承。书中向你表明:理解底层实现模型,可以极大地提高你的编码效率。Lippman澄清了那些关于C++系统开销与复杂性的各种错误信息和猜测,指出了其中某些成本和利益交换确实存在。他在书中详述了各种实现模型,指出了它们的发展方向以及促使其发展的根本原因。本书涵盖了C++对象模型的语意暗示,并指出了这个模型是如何对程序造成影响的。
\r\n
contents\r\n1 Object Lessons l\r\nLayout Costs for Adding Encapsulation 5\r\n1.1 The C++ Object Model 6\r\nA simple object model 6/ A table-driven object model 7/ The C++ object model/ How the object model effects programs\r\n1.2 A Keyword Distinction 12\r\nKeywords schmeewords 13 / The politically correct struct 16\r\n1.3 An Object Distinction 18\r\nThe type of a pointer 24/ Adding polymorphism 25\r\n2 The Semantics of Constructors 31\r\n2.1 Default Constructor Construction 32\r\nMember class object with default constructor 34/ Base class with default constructor 37/ Class with a virtual function 37/ Class with a virtual base class 38 / Summary 39\r\n2.2 Copy Constructor Construction 40\r\nDefault memberwise initialization 41 / Bitwise copy semantics 43 / Bitwise copy semantics—Not! 45 / Resetting the Virtual Table Pointer 45 / Handling the Virtual Base Class Subobject 47\r\n2.3 Program Transformation Semantics 50\r\nExplicit initialization 50/ Argument initialization 51 / Return value initialization 53 / Optimization at the user level 54/ Optimization at the compiler level 55 / The copy constructor: to have or to have not? 59 / Summary 61\r\n2.4 Member Initialization List 62\r\n3 The Semantics of Data 69\r\n3.1 The Binding of a Data Member 72\r\n3.2 Data Member Layout 75\r\n3.3 Access of a Data Member 72\r\nStatic data members 78 / Nonstatic data members 80\r\n3.4 Inheritance and the Data Member 82\r\nInheritance without polymorphism 83 / Adding polymorphism 87/ Multiple inheritance 91 / Virtual inheritance 95\r\n3.5 Object Member Efficiency 101\r\n3.6 Pointer to Data Members 106\r\nEfficiency of pointers to members 109\r\nThe Semantics of Function 113\r\n4.1 Varieties of Member Invocation 114 \r\n Nonstatic member functions 114/ Virtual member functions 120/ Static member functions 121 /\r\n4.2 Virtual Member Functions 124\r\nVirtual functions under MI 131 / Virtual functions underg virtual inheritance 138\r\n4.3 Function Efficiency 139\r\n4.4 Pointer-to-Member Functions 144\r\nSupporting pointer-to-virtual member functions 145 / Pointer-to-member functions under Ml 147/ Pointer-to-member efficiency 149\r\n4.5 Inline Functions 151\r\nFormal arguments 154/ Local variables 155\r\nSemantics of Construction, Destruction, and Copy 151\r\nPresence of pure virtual destructor 160/ Presence of a virtual specification 161 / Presence of const within a virtual specification 162/ A reconsidered class declaration 162\r\n5.1 Object Construction without Inheritance 163 Abstract data type 165/ Concrete base class 168\r\n5.2 Object Construction under Inheritance 172\r\nVirtual inheritance 176/ The semantics of the vptr initial\r\nization 179\r\n5.3 Object Copy Semantics 184\r\n5.4 Object Efficiency 190 \r\n5.5 Semantics of Destruction 196\r\n6 Runtime Semantics 201\r\n6.1 Object Construction and Destruction 203\r\nGlobal objects 205/ Local static objects 209/ Arrays of objects 211 / Default constructors and arrays 214\r\n6.2 Operators new and delete 215 The semantics of new arrays 218\r\n6.3 Temporary Objects 227 A temporary myth 235\r\n7 On the Cusp of the Object Model 239\r\n7.1 Templates 239\r\nTemplate instantiation 241 / Error reporting within a template 244 / Member function instantiation 250\r\n7.2 Exception Handling 254\r\nA quick review of exception handling 256 / Exception handling support 260\r\n7.3 Runtime Type Identification 264\r\nIntroducing a type safe downcast 266 / A type safe dynamic cast 267/ References are not pointers 269/ Typeid Operator 270\r\n7.4 Efficient, but Inflexible 272\r\nDynamic Shared Libraries 272 / Shared Memory 272\r\nIndex 275