《C&C++代码锦囊:实用开发者指南》PDF下载

  • 购买积分:17 如何计算积分?
  • 作  者:(美)爱立森(Allison
  • 出 版 社:北京:科学出版社
  • 出版年份:2004
  • ISBN:7030124693
  • 页数:570 页
图书介绍:本书主要提供了C和C++的大量编程范例,对于进行实用开发的人员具有很大的借鉴和指导意义。各类读者均能从中获得裨益,提高C和C++的编程水平。全书编写水平较高,举例丰富而有代表性。

C++:The Making of a Standard 1

PartⅠ Preliminaries 9

1 A Better C 11

A Tale Of Two Languages 11

Incremental Journey 12

The Type System 12

Function Prototypes 13

Type-safe Linkage 17

References 19

Type-safe I/O 20

Standard Streams 21

Formatting 24

Manipulators 29

Function Overloading and Function Templates 32

Operator Overloading 32

Inline Functions 34

Default Arguments 35

new and delete 36

Statement Declarations 37

Standard Library Features 38

C Compatibility 38

Summary 40

2 Pointers 40

Programming on the Edge 40

The Basics 40

Pointer Arithmetic 44

Pass-By-Reference Semantics 48

Generic Pointers 49

const Pointers 50

Pointers and One-Dimensional Arrays 52

Arrays as Parameters 56

Arrays of Strings 59

Pointers and Multidimensional Arrays 62

Higher and Deeper 64

Pointers to Functions 68

Pointers to Member Functions 71

Encapsulation and Incomplete Types 73

Summary 78

3 The Preprocessor 79

The #include Directive 79

Other Preprocessor Directives 80

Predefined Macros 83

Conditional Compilation 85

Preprocessing Operators 86

Implementing assert 88

Macro Magic 89

Character Sets,Trigraphs,and Digraphs 93

Phases of Translation 96

Summary 97

4 The Standard C Library,Part Ⅰ 98

99

102

109

115

118

5 The Standard C Library,Part Ⅱ 118

119

122

125

Appendix 5.1:Character Sets 127

Code Pages 129

Character Set Standards 130

ISO 10646 130

Unicode 131

6 The Standard C Library,Part Ⅲ 131

132

132

138

138

140

142

142

va_list s As Arguments 143

An Application 146

Conclusion 150

Appendix 6.1:Floating-point Number Systems 151

Part Ⅱ Key Concepts 159

7 Abstraction 161

Data Abstraction 161

Operator Overloading 168

Concrete Data Types 173

Type Abstraction 180

Function Abstraction 181

Summary 184

8 Templates 185

Generic Programming 187

Function Templates 187

Class Templates 189

Template Parameters 194

Template Specialization 196

Summary 199

9 Bit Manipulation 202

Bitwise Operators 202

Accessing Individual Bits 204

Large Bitsets 209

The bitset Template 224

Wish List 224

Bit Strings 224

The vectorTemplate Specialization 227

Summary 228

10 Conversions and Casts 229

Integral Promotion 229

Demotions 233

Arithmetic Conversions 235

Function Prototypes 237

Explicit Conversions 239

Function-style Casts 240

Const Correctness 240

User-Defined Conversions 243

Beefing up operator[] 249

New-Style Casts 252

Summary 253

What s In a Name? 255

Scope 255

11 Visibility 255

Minimal Scoping 258

Class Scope 259

Nested Classes 265

Local Classes 266

Classic Namespaces 268

Namespace Scope 269

Lifetime 272

Lifetime of Temporaries 275

Linkage 276

Type-safe Linkage 280

Summary 281

Language Linkage 281

12 Control Structures 283

Structured Programming 283

Branching 290

Nonlocal Branching 296

Signals 300

Summary 305

References 305

13 Exceptions 306

Error Handling Alternatives 306

Stack Unwinding 314

Catching Exceptions 316

Standard Exceptions 318

Constructors and Exceptions 322

Resource Management 322

Memory Management 330

Exception Specifications 331

An Error-Handling Strategy 333

Summary 337

14 Object-oriented Programming 338

Inheritance 342

Heterogeneous Collections 343

Virtual Functions and Polymorphism 344

Abstract Base Classes 347

Case Study:A Framework for Object Persistence 350

Database Access 353

Mapping Objects to Relational Schema 354

PFX Architecture 356

A Code Walkthrough 359

Summary 379

Part Ⅲ Leveraging the Standard Library 381

15 Algorithms 383

Complexity 386

Generic Algorithms 388

Function Objects 392

Function Taxonomy 394

Function Object Adapters 395

Algorithm Taxonomy 396

16 Containers and Iterators 398

Summary 399

References 399

Standard Containers 401

Iterators 402

Iterator Taxonomy 403

Special-Purpose Iterators 405

Container Adapters 408

Associative Containers 409

Applications 409

Non-STL Containers 417

Summary 419

17 Text Processing 421

scanf 421

printf 427

Substrings 429

The Standard C++ String Class 436

String Streams 440

Wide Strings 441

Summary 442

18 File Processing 443

Filters 443

Binary Files 446

Record Processing 448

Temporary Files 454

Portability 455

POSIX 455

File Descriptors 456

Copying Files via Descriptors 456

Reading Directory Entries 458

Redirecting Standard Error 462

Encapsulating Directory Operations 466

Summary 471

19 Time and Date Processing 472

Julian Day Encoding 475

Date Classes for Real Work 495

Calculating the Week of the Year 521

Summary 522

Reference 522

20 Dynamic Memory Management 523

Ragged Arrays 523

Using the Heap in Standard C 525

The C++ Free Store 529

Deep versus Shallow Copy 530

Handling Memory Allocation Failure 533

Overriding new and delete 534

Placement new 535

Managing the Heap 538

Avoiding Memory Management 539

Summary 546

Appendices 547

A C/C++ Compatibility 547

B Standard C++ Algorithms 549

C Function Objects and Adapters 558

Function Objects 558

Function Object Adapters 560

D Annotated Bibliography 561

The C Practitioner s Booklist 561

The C++ Practitioner s Booklist 562

Index 565