《absolute c++ second edition P945》求取 ⇩

Chapter 1C++ BASICS1

1.1 INTRODUCTION TO C+2

Origins of the C++ Language2

C++ and Object-Oriented Programming3

The Character Of C+++3

C++ Terminology y4

A Sample C++ Program y4

1.2 VARIABLES, EXPRESSIONS, AND ASSIGNMENT STATEMENTS6

Identifiers6

Variables8

Assignment Statements10

Pitfall: Uninitialized Variables12

Tip: Use Meaningful Names13

More Assignment Statements13

Assignment Compatibility14

Literals15

Escape Sequences17

Naming Constants17

Arithmetic Operators and Expressions19

Integer and Floating-Point Division21

Pitfall: Division and whole Number22

Type Casting23

Increment and Decrement Operators25

Pitfall: Order of Evaluation27

1.3 CONSOLE NPT/OUPU28

output Using cout28

New Lines in Output29

Tip: End Each Program with \n or endl30

Formaing for Numbers with a Decimal Point31

Output with cerr32

Input Using cin32

Tip: Line Breaks in l/O34

1.4PROGRAM STYLE35

Comments35

1.5LIBRARIES AND NAMESPACES36

Libraries and include Directives36

Namespaces37

Pitfall: Problems with Libra Names38

Chapter Summa38

Answers to Self-Test Exercises39

Programming Projects41

Chapter 2 FLOW Of CONTROL45

2.1 BOOLEAN EXPRESSION46

Building Boolean Expressions46

Pitfall: Strings of Inequalities47

Evaluating Boolean Expressions48

Precedence Rule50

Pitfall: Integer Values Can Be Used as Boolean Values54

2.2 BRANCHING MECHANISMS57

if-else Statements57

Compound Statements57

Pitfall: Using in Place of - -59

Omiing the else61

Nested Statement62

Multiway if-else Statement62

The switch Statement62

Pitfall: Forgeing a break in a switch Statement66

Tip: Use switch Statements for Menu66

Enumeration Types66

The Conditional Operation67

2.3 LOOPS69

The while and do-while Statements69

Increment and Deement Operators Revisited72

The Comma Operator75

The for Statement76

Tip: Repeat-N-Times Loops79

Pitfall: Extra Semicolon in a for Statement79

Pitfall: infinite Loops80

The break and continue Statement83

Nested Loops86

Chapter Summa86

Answers to Self-Test Exercises87

Programming Projects92

Chapter 3 FUNCTION BASICS95

3.1 PREDEFINED FUNCTIONS96

Predefined Funions That Retu a Value96

Predefined void Functions101

A Random Number Generator103

3.2 PROGRAMMER-DEFINED FUNCTIONS108

Defining Functions That Return a Value108

Alternate Form for Function Declarations111

Pitfall: Arguments in the Wrong Order m111

Pitfall: Use the Terms Parameterand Argument in111

Functctions Calling Functions112

Example: A Rounding Function112

Functions That Return a Boolean Value114

Defining void Functions115

retuct Statements in void Funions117

Preconditions and Postconditions119

main is a Function119

Recursive Functions120

3.3 SCOPE RULES121

Local Variables122

Procedural Abstraion122

Global Constants and Global Variables125

Blocks128

Nested Scopes129

Tip: Use Funion Calls in Branching and Loop Statements129

Variables Declared in a for Loop130

Chapter Summary131

Answers to Self-Test Exercises131

Programming Projects135

Chapter 4 PARAMETERS AND OVERLOADING139

4.1 PARAMETERS140

Call-by-Value Parameters140

A Fit Look at Call-by-Reference Parameters143

Call-by-Reference Mechanism in Detail145

Constant Reference Parameters147

Example: The swapValues Function148

Tip: Think of Actions, Not Code149

Mixed Parameter Lists150

Tip: What Kind of Parameter to Use151

Pitfall: Inadvertent Local Variables152

Tip: Choosing Formal Parameter Names155

Example: Buying Pizza155

4.2 OVERLOADING AND DEFAULT ARGUMENTS158

Introduction to overloading159

Pitfall: Automatic Type Conversion and Overloading161

Rules for Resolving overloading163

Example: Revised Pizza-Buying Program164

Default Arguments167

4.3 TESTING AND DEBUGGING FUNCTIONS169

The assert Mao169

Stubs and Drivers170

Chapter Summary176

Answers to Self-Test Exercises176

Programming Projects176

Chapter5 ARRAYS181

5.1 INTRODluCTION TO ARRAYS182

Declaring and Referencing Arrays182

Tip: Use for Loops with Aays185

Pitfall: Aay Indexes Always Sta with Zero185

Tip: Use a Defined Constant for the Size of an Aay185

Aays in Memo186

Pitfall: Aay Index Out of Range187

Initializing Aays189

5.2 ARRAYS IN FUNCTIONS191

Indexed Variables as Funion Arguments191

Entire Aays as Funion Arguments193

TheconstParameter Modifier196

Pitfall: Inconsistent Use of const Paramete198

Functions That Retum an Array198

Example: Production Graph199

5.3 PROGRAONG WITH ARRAYS204

Paially Filled Arrays204

Tip: Do Not Skimp on Formal Paramete205

Example: Searching an Array207

Example: Soing an Array210

5.4 MULTIDlAENSIONAL ARRAYS214

Multidimensional Array Basics214

Multidimensional Array Parameters216

Example: Two-Dimensional Grading Program217

Chapter Summa222

Answers to Self-Test Exercises223

Programming Projects227

Chapter 6 STRUCTURES AND CLASSES235

6.1 STRUCTURES236

Structure Types238

Pitfall: Forgeing a Semicolon in a Structure Definition242

Structures as Function Arguments242

Tip: Use Hierarchical Structures243

Initializing Structures246

6.2 CLASSES249

Defining Classes and Member Functions249

Encapsulation254

Public and Private Members255

Accessor and Mutator Functions259

Tip: Separate Interface and implementation261

Tip: A Test for Encapsulation262

Structures versus Classes263

Tip: Thinking Objects265

Chapter Summary265

Answers to Self-Test Exercises266

Programming Projects268

Chapter 7 CONSTRUCTORS AND OTHER TOOLS271

7.1CONSTRUCTORS272

ConstructoTDefinitions272

Pitfall: Constructors with No Arguments277

Explicit Constructor Calls279

Tip: Always Include a Default Constructor279

Example: BonkAccount Class282

Class Type Member Variables288

7.2MORE TOOLS291

The const Parameter Modifier292

Pitfall: Inconsistent Use of const294

Inline Functions298

Static Members299

Nested and Local Class Definitions304

7.3VECTORS—A PREVIEWS OF THE STANDARD TEMPLATE LIBRARY304

Vector Basics305

Pitfall: Using Square Brackets beyond the Vector Size308

Tip: Vector Assignment Is Well Behaved309

Efficiency Issues309

Chapter Summa311

Answers to Self-Test Exercises311

Programming Projects314

Chapter 8 OPERATOR OVERLOADING, FRIENDS, AND REFERENCES317

8.1BASIC OPERATOR OVERLOADING318

Overloading Basics319

Tip: A Constructor Can Return an Object324

Returning by const Value325

Tip: Retuing Member Variables of a Class Type328

Overloading Una Operators329

Overloading as Members Functions330

Tip: A Class Has Access to All its objects332

Overloading Function Application ( )333

Pitfall: Overloading , ll, and the Comma Operator334

8.2FRIEND FUNCTIONS AND AUTOMATk TYPE CONVERSION334

Constructors for Automatic Type Conversion334

Pitfall: Member Operators and Automatic Type Conversion335

Friend Functions336

Pitfall: Compilers without Friends340

Friend Classes340

8.3REFERENCES AND MORE OVERLOADED OPERATORS342

References342

Pitfall: Returning a Reference to Ceain Member Variables343

Overloading and344

Tip: What Mode of Retued Value to Use351

The Assignment Operator353

Overloading the Increment and Deement Operato354

Overloading the Array operator357

Overloading Based on L-Value veus R-value359

Chapter Summa359

Answers to self-Test Exercises360

Programming Projects362

Chapter 9 STRINGS367

9.1 AN ARRAY TYPE FOR STRINGS368

C-String Values and C-String Variables369

Pitfall:Using and- with C-Strings373

Other Functions in 375

C-String Input and Output379

9.2 CHARACTER MANIPULATION TOOLS382

Character l/O382

The Member Functions get and put382

Example: Checking Input Using a Newfine Function385

Pitfall: Unexpected \n in Input386

The putback, peek, and ignore Member Functions388

Character-Manipulating Functions390

Pitfall: toupper and tolower Retu int Values392

9.3THE STANDARD CLASS string394

Introduction to the Standard Class string394

l/O with the Class string396

Tip: More Versions of getline401

Pitfall: Mixing cin variable; and getline401

String Processing with the Class string402

Example: Palindrome Testing406

Converting between string Objes and C-Strings411

Chapter Summa411

Answers to Self-Test Exercises412

Programming Projes415

Chapter 10 POINTERS AND DYNAMIC ARRAYS421

10.1 POINTERS422

Pointer Variables423

Basic Memo Management431

Pitfall: Dangling Pointers434

Dynamic Variables and Automatic Variables434

Tip: Define Pointer Types435

Pitfall: Pointers as Call-by-Value Parameters437

Uses for Pointers439

10.2 DYNAMIC ARRAYS439

Array Variables and Pointer Variables439

Creating and Using Dynamic Aays441

Example: A Function That Retus an Aay445

Pointer Arithmetic447

Multidimensional Dynamic Aays448

10.3 CLASSES POINTERS AND DYNAC ARRAYS451

The -> Operator451

The this Pointer452

Overloading the Assignment Operator453

Example: A Class for Paially Filled Aays456

Destructors463

Copy Constructors465

Chapter Summary469

Answers to Self-Test Exercises470

Programming Projects472

Chapter 11 SEPARATE COMPILATION AND NAMESPACES475

11.1SEPARATE COMPILATION476

Encapsulation Reviewed477

Header Files and Implementation Files478

Example: DigitalTime Class486

Tip: Reusable Components487

Using #ifndef487

Tip: Defining Other Libraries490

11.2NAMESPACES491

Namespaces and using Directives491

Creating a Namespace493

Using Declarations496

Qualifying Names498

Tip: Choosing a Name for a Namespace500

Example: A Class Definition in a Namespace501

Unnamed Namespaces502

Pitfall: Confusing the Global Namespace and the Unnamed Namespace509

Tip: Unnamed Namespaces Replace the static Qualifer509

Tip: Hiding Helping Functions509

Nested Namespaces510

Tip: What Namespace Specification Should You Use?510

Chapter Summa514

Answers to Self-Test Exercises514

Programming Projects516

Chapter 12 STREAMS AND FILE l/O519

12.1 l/O STREAMS521

File l/O521

Pitfall: Restrictions on Stream Variables526

Appending to a File526

Tip: Another Syntax for Opening a File528

Tip: Check That a File Was Opened Successfully529

Character l/O532

Checking for the End of a File533

12.2 TOOLS FOR STREAM l/O537

File Names as Input537

Formaing output with Stream Functions538

Manipulators542

Saving Flag Seings543

More Output Stream Member Functions544

Example: Cleaning Up a File Format546

Example: Editing a Text File548

12.3STREAM HIERARCHIES: A PREVIEW OF INHERITANCE551

Inheritance among Stream Classes551

Example: Another newline Function553

12.4RANDOM ACCESS TO FILES557

Chapter Summa559

Answe to Self-Test Exercises559

Programming Projects562

Chapter 13 RECURSION571

13.1RECURSIVE void FUNCTIONS573

Example: Vertical Numbers573

Tracing a Recursive Call576

A Closer look at Recuion579

Pitfall: Infinite Recursion580

Stacks for Recuion582

Pitfall: Stack overflow584

Recursion versus iteration584

13.2 RECURSIVE FUNCTIONS THAT RETURN A VALUE585

General Form for a Recursive Function That Retus a Value585

Example: Another Powers Function586

13.3 THINKING RECURSIVELY591

Recursive Design Techniques591

Bina Search592

Chapter Summa601

Answe to Self-Test Exercises601

Programming Projects606

Chapter 14 INHERITANCE609

14.1 INHERITANCE BASICSDerived Classes610

Constructo in Derived Classes620

Pitfall: Use of Private Member Variables from the Base Class622

Pitfall: Private Member Functions Are Effectively Not Inherited624

The protected Qualifier624

Redefinition of Member Functions627

Redefining veus Overloading629

Access to a Redefined Base Function630

Functions That Are Not Inherited631

14.2 PROGRAMANING WITH INHERITANCE633

Assignment Operato and Copy Constructors in Derived Classes633

Destructors in Derived Classes634

Example: Paially Filled Array with Backup634

Pitfall: Same Object on Both Sides of the Assignment Operator643

Example: Alteate Implementation of PFArrayDBak644

Tip: A Class Has Access to Private Membe of All Objects of the Class647

Tip: “Is a” versus “Has a”647

Protected and Private Inheritance648

Multiple Inheritance649

Chapter Summa650

Answe to Self-Test Exercises650

Programming Projects652

Chapter15 POLYMORPHISM AND VIRTUAL FUNCTIONS655

15.1VIRTUAL FUNCTION BASICS656

LAte Binding656

Virtual Functions in C+++657

Tip: The Virtual Property Is Inherited664

Tip: When to Use a Virtual Function664

Pitfall: Omiing the Definition of a Virtual Member Function665

Abstract Classes and Pure Viual functions665

Example: An Abstract Class667

15.2 POINTERS AND VIRTU FUNCTIONS669

Virtual Functions and Extended Type Compatibility669

Pitfall: The Slicing Problem674

Tip: Make Destructo Viual675

Downcasting and Upcasting676

How C++ Implements Viual Functions678

Chapter Summa679

Answe to Self-Test Exeises679

Programming Projects680

Chapter 16 TEMPLATES683

16.1FUNCTION TEMPLATES684

Syntax for Function Templates686

Pitfall: Compiler Complitions689

Tip: How to Define Templates690

Example: A Generic Soing Funion692

Pitfall: Using a Template with an Inappropriate Type696

16.2 CLASS TEMPLATES698

Syntax for Class Templates698

Example: An Aay Template Class703

The vector and basic-string Templates709

16.3 TEMPALTES AND INHERITANCE709

Example: Template Class for a Partially Filled Array with Backup710

Chapter Summary716

Answers to Self-Test Exercises716

Programming Projects720

Chapter 17 LINKED DATA STRUCTURES721

17.1 NODES AND LINKED LISTS723

Nodes723

Linked Lists728

Inserting a Node at the Head of a List730

Pitfall: Losing Nodes733

Inseing and Removing Nodes Inside a List734

Pitfall: Using the Assignment Operator with Dynamic Data Structures738

Searching a Linked List738

Example: A Generic Soing Template Version of Linked List Tools743

17.2LINKED LIST APPLICATIONS747

Example: A Stack Template Class748

Example: A Queue Template Class755

Tip: A Comment on Namespaces758

Friend Classes and Similar Alternatives759

17.3 ITERATORS762

Pointers as Iterators762

Iterator Classes763

Example: An Iterator Class764

17.4 TREES771

Tree Propeies772

Example: A Tree Template Class775

Chapter Summa780

Answers to Self-Test Exercises780

Programming Projects788

Chapter18 EXCEPTION HANDLING793

18.1EXCEPTION HANDLING BASICS795

A Toy Example of Exception Handling795

Defining Your Own Exception Classes804

Multiple Throws and Catches806

Pitfall: Catch the More Specific Exception First808

Tip: Exception Classes Can Be Trivial809

Throwing an Exception in a Function810

Exception Specification810

Pitfall: Exception Specification in Derived Classes814

18.2PROGRAMMING TECHNIQUES FOR EXCEPTION HANDLING815

When to Throw an Exception815

Pitfall: Uncaught Exceptions817

Pitfall: Nested try-catch Blocks817

Pitfall: overuse of Exceptions818

Exception Class Hierarchies818

Testing for Available Memo818

Rethrowing an Exception819

Chapter Summa819

Answers to Self-Test Exercises820

Programming Projects821

Chapter19 STANDARD TEMPLATE LIBRARY823

19.1 ITERATORS825

Iterator Basi825

Kinds of Iterators831

Constant and Mutable Iterators834

Revee Iterators836

Pitfall: Compiler Problems838

Other Kinds of Iterato838

19.2 CONTAINERS839

Sequential Containers839

Pitfall: Iterato and Removing Elements844

Tip: Type Definitions in Containers844

The Container Adapters stack and queue845

The Associative Containe set and nap846

Efficiency851

19.3 GENERc: ALGORITHMS853

Running Times and Big-ONotation854

Container Access Running Times858

Nonmodifying Sequence Algorithms859

Modifying Sequence Algorithms863

Set Algorithms865

Soing Algorithms865

Chapter Summa867

Answers to Self-Test Exercises868

Programming Projects870

Chapter 20 PATENS AND UML875

20.1 PATTERNS876

Adapter Patte877

The Model-View-Controller Paern877

Example: A Soing Pattern879

Efficiency of the Soing Pattern885

Tip: Pragmatics and Paes886

Pattern Formalism886

20.2 UML887

Histo of UML887

UML Class Diagrams888

Class Interactions889

Chapter Summa889

Answe to Self-Test Exercises889

Programming Projects891

Appendix 1 C+++ Keywords893

Appendix 2 Precedence of operators895

Appendix 3 The ASCII Character Set899

Appendix 4 Some Libra Functions901

Arithmetic Funions901

Input and Output Member functions902

Charaer Functions903

C-String Functions904

string Class Functions906

Random Number Generator907

Trigonometric functions908

Appendix5 Old and New Header Files909

Further Reading911

lndex913

《absolute c++ second edition P945》由于是年代较久的资料都绝版了,几乎不可能购买到实物。如果大家为了学习确实需要,可向博主求助其电子版PDF文件。对合法合规的求助,我会当即受理并将下载地址发送给你。