当前位置:首页 > 工业技术
C++ Gotchas  影印本
C++ Gotchas  影印本

C++ Gotchas 影印本PDF电子书下载

工业技术

  • 电子书积分:12 积分如何计算积分?
  • 作 者:(美)杜赫斯特著
  • 出 版 社:北京:中国电力出版社
  • 出版年份:2003
  • ISBN:7508314948
  • 页数:325 页
图书介绍:C++是一门高效率但是复杂的编程语言,因为它的复杂性,使得程序员有机会去面对形形色色的各种设计和编程错误。如何去规避这些陷阱,编写出更具重用性和易维护的C++代码,正是本书的目标所在。作者Stephen C. Dewhurst结合了将近二十年的C++开发经验,罗列了最常见的99个小问题,并详细阐述这些问题的解决之道,让读者在不知觉之间掌握C++的高级编程技巧,充分领悟C++的细微之处。阅读本书,必会对实际工作带来巨大的帮助。
《C++ Gotchas 影印本》目录
标签:影印本 影印

Chapter 1 Basics 1

Gotcha#1:Excessive Commenting 1

Gotcha#2:Magic Numbers 4

Gotcha#3:Global Variables 6

Gotcha#4:Failure to Distinguish Overloading from Default Initialization 8

Gotcha#5:Misunderstanding References 10

Gotcha#6:Misunderstanding Const 13

Gotcha#7:Ignorance of Base Language Subtleties 14

Gotcha#8:Failure to Distinguish Access and Visibility 19

Gotcha#9:Using Bad Language 24

Gotcha#10:Ignorance of Idiom 26

Gotcha#11:Unnecessary Cleverness 29

Gotcha#12:Adolescent Behavior 31

Chapter 2 Syntax 35

Gotcha#13:Array/Initializer Confusion 35

Gotcha#14:Evaluation Order Indecision 36

Gotcha#15:Precedence Problems 42

Gotcha#16:for Statement Debacle 45

Gotcha#17:Maximal Munch Problems 48

Gotcha#18:Creative Declaration-Specifier Ordering 50

Gotcha#19:Function/Object Ambiguity 51

Gotcha#20:Migrating Type-Qualifiers 52

Gotcha#21:Self-Initialization 53

Gotcha#22:Static and Extern Types 55

Gotcha#23:Operator Function Lookup Anomaly 56

Gotcha#24:Operator->Subtleties 58

Chapter 3 The Preprocessor 61

Gotcha#25:#define Literals 61

Gotcha#26:#define Pseudofunctions 64

Gotcha#27:Overuse of#if 66

Gotcha#28:Side Effects in Assertions 72

Chapter 4 Conversions 75

Gotcha#29:Converting through void 75

Gotcha#30:Slicing 79

Gotcha#31:Misunderstanding Pointer-to-Const Conversion 81

Gotcha#32:Misunderstanding Pointer-to-Pointer-to-Const Conversion 82

Gotcha#33:Misunderstanding Pointer-to-Pointer-to-Base Conversion 86

Gotcha#34:Pointer-to-Multidimensional-Array Problems 87

Gotcha#35:Unchecked Downcasting 89

Gotcha#36:Misusing Conversion Operators 90

Gotcha#37:Unintended Constructor Conversion 95

Gotcha#38:Casting under Multiple Inheritance 98

Gotcha#39:Casting Incomplete Types 100

Gotcha#40:Old-Style Casts 102

Gotcha#41:Static Casts 103

Gotcha#42:Temporary Initialization of Formal Arguments 106

Gotcha#43:Temporary Lifetime 110

Gotcha#44:References and Temporaries 112

Gotcha#45:Ambiguity Failure of dynamic_cast 116

Gotcha#46:Misunderstanding Contravariance 120

Chapter 5 Initialization 125

Gotcha#47:Assignment/Initialization Confusion 125

Gotcha#48:Improperly Scoped Variables 129

Gotcha#49:Failure to Appreciate C++ s Fixation on Copy Operations 132

Gotcha#50:Bitwise Copy of Class Objects 136

Gotcha#51:Confusing Initialization and Assignment in Constructors 139

Gotcha#52:Inconsistent Ordering of the Member Initialization List 141

Gotcha#53:Virtual Base Default Initialization 142

Gotcha#54:Copy Constructor Base Initialization 147

Gotcha#55:Runtime Static Initialization Order 150

Gotcha#56:Direct versus Copy Initialization 153

Gotcha#57:Direct Argument Initialization 156

Gotcha#58:Ignorance of the Return Value Optimizations 158

Gotcha#59:Initializing a Static Member in a Constructor 163

Chapter 6 Memory and Resource Management 167

Gotcha#60:Failure to Distinguish Scalar and Array Allocation 167

Gotcha#61:Checking for Allocation Failure 171

Gotcha#62:Replacing Global New and Delete 173

Gotcha#63:Confusing Scope and Activation of Member new and delete 176

Gotcha#64:Throwing String Literals 177

Gotcha#65:Improper Exception Mechanics 180

Gotcha#66:Abusing Local Addresses 185

Gotcha#67:Failure to Employ Resource Acquisition Is Initialization 190

Gotcha#68:Improper Use of auto_ptr 195

Chapter 7 Polymorphism 199

Gotcha#69:Type Codes 199

Gotcha#70:Nonvirtual Base Class Destructor 204

Gotcha#71:Hiding Nonvirtual Functions 209

Gotcha#72:Making Template Methods Too Flexible 212

Gotcha#73:Overloading Virtual Functions 214

Gotcha#74:Virtual Functions with Default Argument Initializers 216

Gotcha#75:Calling Virtual Functions in Constructors and Destructors 218

Gotcha#76:Virtual Assignment 220

Gotcha#77:Failure to Distinguish among Overloading,Overriding,and Hiding 224

Gotcha#78:Failure to Grok Virtual Functions and Overriding 230

Gotcha#79:Dominance Issues 236

Chapter 8 Class Design 241

Gotcha#80:Get/Set Interfaces 241

Gotcha#81:Const and Reference Data Members 245

Gotcha#82:Not Understanding the Meaning of Const Member Functions 248

Gotcha#83:Failure to Distinguish Aggregation and Acquaintance 253

Gotcha#84:Improper Operator Overloading 258

Gotcha#85:Precedence and Overloading 261

Gotcha#86:Friend versus Member Operators 262

Gotcha#87:Problems with Increment and Decrement 264

Gotcha#88:Misunderstanding Templated Copy Operations 268

Chapter 9 Hierarchy Design 271

Gotcha#89:Arrays of Class Objects 271

Gotcha#90:Improper Container Substitutability 273

Gotcha#91:Failure to Understand Protected Access 277

Gotcha#92:Public Inheritance for Code Reuse 281

Gotcha#93:Concrete Public Base Classes 285

Gotcha#94:Failure to Employ Degenerate Hierarchies 286

Gotcha#95:Overuse of Inheritance 287

Gotcha#96:Type-Based Control Structures 292

Gotcha#97:Cosmic Hierarchies 295

Gotcha#98:Asking Personal Questions of an Object 299

Gotcha#99:Capability Queries 302

Bibliography 307

Index 309

返回顶部